 |
| C# 2005 For discussion of Visual C# 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 15th, 2008, 10:51 PM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dataset
hai sir,
in cs.net application i am using dataset sir . for example there is 5 forms . shall i use separate dataset for each and every winforms or shall i create the library and there shall i create the dataset and connect the library with my application and use that single dataset for all my forms. because i feel complicated to create the relations between datatables if i use library.
thank you sir
|
|

April 16th, 2008, 02:16 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi there.
It depends on what you are doing really. You have not given us much of an overview of the scenario. However, using a single DataSet does have significant advantages since it does a lot of the maintenence leg-work for you when working with relational data.
If its too complicated, then learn how to do it :)
If you have a strict deadline that does not offer the time to learn how to do it, talk to your manager/lead developer, its an important decision and you need to know how to make itm and its down to your superiors to get you up to speed.
If you dont want to learn how to do it, I think you may be in the wrong industry ;)
A lot of the creation of the DataSet can actually be done for you by using the wizards in VS.
Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://robzyc.spaces.live.com
|
|

April 16th, 2008, 08:36 AM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hello sir, i am not saying about to try . i said coding logic is complex if i use library . so please encourge me. dont discourge me. thank you
|
|

April 16th, 2008, 09:14 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
So dont use library if you are feeling uneasy in doing so, since you are going to use 5 forms only, use separate dataset for every form, name it like dsForm1,dsForm2...,etc..,
Well if you have time, then dont hesitate to experiment with some new ideas. :)
-- Abhishek
|
|

April 16th, 2008, 09:17 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
We are not trying to discourage you, but we are finding it hard to understand what you mean.
If you are trying to display the exact same data on 5 very similar forms then having a class that does that work for you and returns 'the same' dataset each time will work much better than writing the code 5 times in 5 different forms.
Is that what you meant?
/- Sam Judson : Wrox Technical Editor -/
|
|

April 16th, 2008, 09:25 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
There are a number of design implications to using different DataSets for each form, one of the most important is maintainability.
DataSets are weakly-typed (i.e. everything is stored as Object). You can overcome this by generating a strongly-typed DataSet based on the current data model. However, if ANY of this changes, then you need to update your generated DataSet.
I dont understand how the "coding logic is complex", since you gave no idea as to how your applcation is built, but I am pretty sure ANY developer will agree with me that "if the logic is 'too complicated' to change", then there is something wrong with the logic. Code needs to be maintainable, and a large part of that is the ability for it to change and evolve. If that means ripping the guts out of a part of it, then it may be required. If not, and your superiors give you heat, explain the situation to them. If they still say "we need it done" then comment everything and hack away. :)
Like I said before, you can create a DataSet using the wizard, that will handle the creation of the DataRelation objects required to maintain your data. If you do not understand relational data.. Then.. Wow.. Have a chat with your boss and get them to explain it to you?
Rob
http://robzyc.spaces.live.com
|
|

April 16th, 2008, 01:17 PM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sir i clearly exaplain to you,
public static DataSet GlobalExecute(string sp,string dt)
{
if (scon.State == ConnectionState.Closed)
{
scon.Open();
}
SqlDataAdapter sda = new SqlDataAdapter(sp, scon);
DataSet ds = new DataSet();
sda.Fill(ds, dt);
sda.Dispose();
return (ds);
}
sir i am using this code to execute the process. i send the stored procedure name and datatbale name to this function. this function will execute from here sir.
for example :
i call this function like this in my form sir.
string send_sp ="exec sp_insrec 'E101','jones', 700000";
Dataset ds =new Dataset();
ds= lib.GlobalExecute(send_sp,t1);
then i use this dataset [ds] in my form sir.
we can execute the stored procedure in 2 methoths
1. we give stored procedure name and
parmaters.add(@,Sqltype,textbox....)
2. string send_sp ="exec sp_insrec 'E101','jones', 700000"; like this
.
if i use first method i want to send the stored procedure name and how many parameters i am using , parameters data type, from which field the data will send everything.
if use second one . directly i send the string . in that string everthing will be send ie, stored procedure name , and parameters values . then it will execute simply.
pls provide the suggestion which method is best and why ? thank you sir
|
|

April 16th, 2008, 02:58 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
The former is always better, because it avoid many of the inherent errors involved with SQL injection security issues.
However it is slightly more complex to code obviously.
/- Sam Judson : Wrox Technical Editor -/
|
|

April 16th, 2008, 03:47 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Sam is right, the StProc method is definately the way to go, its more efficient and secure.
As for getting the DataView up and running, you are passing the name of the desired table (string dt) to your GlobalExecute method. You can add some extra code where required to hook up a DataView to that table.
So, instantiate your DataSet, get a reference to the table (ds.Tables[string name]), instantiate a DataView based on the DataTable, job done! :)
Rob
http://robzyc.spaces.live.com
|
|

April 16th, 2008, 11:49 PM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thank you
so your solution is
exec sp_insrec 'E101','jones', 700000 is correct . is it ?
|
|
 |