Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
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 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
 
Old June 29th, 2003, 08:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 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.
 
Old June 30th, 2003, 11:24 AM
Registered User
 
Join Date: Jun 2003
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
 
Old June 30th, 2003, 10:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 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.
 
Old July 1st, 2003, 02:43 AM
Authorized User
 
Join Date: Jun 2003
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.
 
Old July 1st, 2003, 03:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 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.
 
Old November 2nd, 2008, 03:14 AM
hu_yang
Guest
 
Posts: n/a
Default

go through the follwoing link , its about dataAdapter.

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

leem.






Similar Threads
Thread Thread Starter Forum Replies Last Post
update dataadapter karenai Visual Basic 2005 Basics 0 February 9th, 2008 10:46 PM
Dataadapter with parameter kau_shuk VS.NET 2002/2003 0 January 4th, 2007 02:43 AM
dataadapter --- dataset thas123 ASP.NET 2.0 Basics 0 December 13th, 2006 08: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 03:42 PM





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