Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 15th, 2008, 10:51 PM
Authorized User
 
Join Date: Mar 2008
Location: chennai, tamilnadu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vgsgowrisankar
Default 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
  #2 (permalink)  
Old April 16th, 2008, 02:16 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
  #3 (permalink)  
Old April 16th, 2008, 08:36 AM
Authorized User
 
Join Date: Mar 2008
Location: chennai, tamilnadu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vgsgowrisankar
Default

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
  #4 (permalink)  
Old April 16th, 2008, 09:14 AM
Authorized User
 
Join Date: May 2007
Location: Hyderabad, Andhra Pradesh, India.
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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
  #5 (permalink)  
Old April 16th, 2008, 09:17 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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 -/
  #6 (permalink)  
Old April 16th, 2008, 09:25 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
  #7 (permalink)  
Old April 16th, 2008, 01:17 PM
Authorized User
 
Join Date: Mar 2008
Location: chennai, tamilnadu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vgsgowrisankar
Default

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







  #8 (permalink)  
Old April 16th, 2008, 02:58 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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 -/
  #9 (permalink)  
Old April 16th, 2008, 03:47 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
  #10 (permalink)  
Old April 16th, 2008, 11:49 PM
Authorized User
 
Join Date: Mar 2008
Location: chennai, tamilnadu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vgsgowrisankar
Default

thank you
so your solution is

 exec sp_insrec 'E101','jones', 700000 is correct . is it ?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill a DataSet from another DataSet kamranzafar C# 1 February 7th, 2007 11:14 AM
Fill(dataset) or dataset.load() salemkoten SQL Server 2005 1 November 2nd, 2006 11:04 PM
Converting a untyped dataset to a typed dataset daphnean Visual Studio 2005 0 July 13th, 2006 01:16 AM
Copy dataset to another dataset kapila VB.NET 2 November 13th, 2005 06:25 AM
Re: SQL Server dataset to ACCESS dataset dazzer ADO.NET 0 March 22nd, 2004 05:28 AM



All times are GMT -4. The time now is 04:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.