|
|
 |
| 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 .
|
 |
|
|
 |

June 29th, 2003, 08:29 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
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.
|

June 30th, 2003, 11:24 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: Danbury, Connecticut, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

June 30th, 2003, 10:54 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
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.
|

July 1st, 2003, 02:43 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Location: Noida, UP, India.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

July 1st, 2003, 03:20 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |