p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

Go Back   p2p.wrox.com Forums > .NET > Other .NET > ADO.NET
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers 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 programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 29th, 2003, 08:29 AM
Friend of Wrox
Points: 3,190, Level: 23
Points: 3,190, Level: 23 Points: 3,190, Level: 23 Points: 3,190, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
Send a message via Yahoo to melvik
Default How many DataAdapter in a Form

Hi, its me again:
I have a problem! Should I add DataAdapter for any table witch Im useing in my form to set my DataSet?!?
ex: lets say I use 3 table: (City, Rigion, Customers) should I have 3 DataAdapters to set my DataSet?!?! I dont guess BUT I HAVE TO ask!

Always:),
Hovik Melkomian.
__________________
Always[:)],
Hovik Melkomian.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 30th, 2003, 11:24 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Danbury, Connecticut, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ParthaChoudhury Send a message via Yahoo to ParthaChoudhury
Default

Well - technically you can use only one data adapter for any number of tables. The dataset is just an in-memory dataholder, it has no knowledge of the underlying datasource. It needs one data adapter to get/set data for a table. It is possible to use one data adapter to create/set for the first table, then re-initialize it and use it for the next and so on. But I prefer to use one for each table. For 2 reasons - first your code is clean. secondly, if you are reading data from multiple tables and also inserting/updating on the same form, you create one data adapter for each table and use it for both reading and writing data for that table. If you use one data adapter for all tables, then you have to create/re-initialize the data adapter 6 times for 3 tables - which does not buy you much and your code gets cluttered.

:D

- Partha
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old June 30th, 2003, 10:54 PM
Friend of Wrox
Points: 3,190, Level: 23
Points: 3,190, Level: 23 Points: 3,190, Level: 23 Points: 3,190, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
Send a message via Yahoo to melvik
Default

Dear Partha:
Im thankful for ur reply. First I m thankful to share ur experience!!
Yes u r right, having DataAdapter for each table will make my code clear & updatable But in the cases witch I just want to show the Data I guess it'll do the best! so could u please give me am example of setting 2/3 Table to a DataAdapter?!?!

Always:),
Hovik Melkomian.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 1st, 2003, 02:43 AM
Authorized User
Points: 215, Level: 4
Points: 215, Level: 4 Points: 215, Level: 4 Points: 215, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Noida, UP, India.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Hovik!

U can use one DataAdapter for updating multiple tables or use seperate DataAdapters for each of the tables...Now, as u said u wanted to display records from more than one table...For that u can use a single DataAdapter like this

strQuery="Select * from customers; Select * from Orders; Select * from Products";
OLEDBDataAdapter objDA = new OLEDBDataAdapter(strQuery,Conn);
objDA.Fill(objDS);

This will make a dataset and create 3 tables in it which u can then scan thru...For updating records in multiple tables, u can use different Command objects and set the "SelectCommand" property of DataAdapter to these command objects before u say objCommand.ExecuteNonQuery()...

Hope this help....

cheers,
debsoft


Quote:
quote:Originally posted by melvik
 Dear Partha:
Im thankful for ur reply. First I m thankful to  share ur experience!!
Yes u r right, having DataAdapter for each table will make my code clear & updatable But in the cases witch I just want to show the Data I guess it'll do the best! so could u please give me am example of setting 2/3 Table to a DataAdapter?!?!

Always:),
Hovik Melkomian.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old July 1st, 2003, 03:20 AM
Friend of Wrox
Points: 3,190, Level: 23
Points: 3,190, Level: 23 Points: 3,190, Level: 23 Points: 3,190, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
Send a message via Yahoo to melvik
Default

Dear Friend:
Thnaks again, but I wonder how can I do this in visual mode?!
bc of some reasons I dont want to type code for anything.
Plz help. (I mean select text of DataAdapterm, ur strQuery)


Always:),
Hovik Melkomian.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old November 2nd, 2008, 02:14 AM
Authorized User
Points: 72, Level: 1
Points: 72, Level: 1 Points: 72, Level: 1 Points: 72, Level: 1
Activity: 5%
Activity: 5% Activity: 5% Activity: 5%
 
Join Date: Aug 2008
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

go through the follwoing link , its about dataAdapter.

http://vb.net-informations.com/dataa...er-dataset.htm

leem.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
update dataadapter karenai Visual Basic 2005 Basics 0 February 9th, 2008 09:46 PM
Dataadapter with parameter kau_shuk VS.NET 2002/2003 0 January 4th, 2007 01:43 AM
dataadapter --- dataset thas123 ASP.NET 2.0 Basics 0 December 13th, 2006 07:58 AM
DataAdapter.Fill() kadesskade VB.NET 2002/2003 Basics 1 July 10th, 2006 02:57 AM
DataSet and DataAdapter Objects cjo ASP.NET 1.0 and 1.1 Basics 4 January 13th, 2006 02:42 PM



All times are GMT -4. The time now is 01:59 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc