ADO.NET (Clear some things up for me)

G

Guest

I've been following some tutorials and reading books and have a basic
grasp of the fundamental ADO.NET commands. But all the books I've read
use a database with only 1 table. My database has many, so:

1. I know there is 1 OleDbConnectino object variable per database
file, but is there one dataAdapter per table/query? (e.g. my tables:
tblCustomer, tblProducts, tblPrices etc etc, so should I have
dataAdapters such as these? daDataAdapterCustomer,
daDataAdapterProducts etc etc?

2. If there is 1 dataAdaptor per table, is there one Datatable per
DataAdaptor? e.g. (dtCustomer, dtProducts, dtPrices).

3. Am I right in thinking that in VB, the database connection
represents the database file, the dataAdapters are the intermediate
'link' to each table and the DataTables are the database tables held in
VB memory?
so I should modify the DataTables and when done save them using the
DataAdapter Update command to save them? (e.g.
daDataAdapterCustomer.Update(dtCustomer)

Sorry I know these are basic questions but I'd like to be 100% certain
before moving on to do more ADO.NET
 
A

Armin Zingler

I've been following some tutorials and reading books and have a
basic grasp of the fundamental ADO.NET commands. But all the books
I've read use a database with only 1 table. My database has many,
so:

1. I know there is 1 OleDbConnectino object variable per database
file, but is there one dataAdapter per table/query? (e.g. my tables:
tblCustomer, tblProducts, tblPrices etc etc, so should I have
dataAdapters such as these? daDataAdapterCustomer,
daDataAdapterProducts etc etc?

Yes, usually one DataAdapter per table.
2. If there is 1 dataAdaptor per table, is there one Datatable per
DataAdaptor? e.g. (dtCustomer, dtProducts, dtPrices).

You could use many DataTables per DataAdapter, but all DataTables would have
the same type, i.e. daCustomer can serve dtCustomerA, dtCustomerB etc.,
where dtCustomerA holds the customers starting with "A" and dtCustomerB
holds the customers starting with "B" (assuming the SelectCommand has a
parameter filtering records by name).

Pseudo code:

Dim dtCustomerA, dtCustomerB

set daCustomers.SelectComamnd parameter value to "A%"
daCustomers.fill(dtCustomerA)

set daCustomers.SelectComamnd parameter value to "B%"
daCustomers.fill(dtCustomerB)
3. Am I right in thinking that in VB, the database connection
represents the database file, the dataAdapters are the intermediate
'link' to each table and the DataTables are the database tables held in
VB memory?

Yes. One DataAdapter is there to synchronize a DataTable with the table in
the database.
so I should modify the DataTables and when done save them using the
DataAdapter Update command to save them? (e.g.
daDataAdapterCustomer.Update(dtCustomer)

Sorry I know these are basic questions but I'd like to be 100% certain
before moving on to do more ADO.NET


You can be even more certain if you ask additional ADO.Net questions in the
ADO.Net group: (because ADO.Net is not tied to VB.Net; you will benefit from
the none-VBers, too)

microsoft.public.dotnet.framework.adonet


Armin
 
C

Cor Ligthert [MVP]

Azis,
1. I know there is 1 OleDbConnectino object variable per database
file, but is there one dataAdapter per table/query? (e.g. my tables:
tblCustomer, tblProducts, tblPrices etc etc, so should I have
dataAdapters such as these? daDataAdapterCustomer,
daDataAdapterProducts etc etc?
Not necessary, if your dataset contains more tables than you can use one
and tell what table you want to use.

http://msdn.microsoft.com/library/d...ystemdatacommondatatablemappingclasstopic.asp
2. If there is 1 dataAdaptor per table, is there one Datatable per
DataAdaptor? e.g. (dtCustomer, dtProducts, dtPrices).

Yes

3. Am I right in thinking that in VB, the database connection
represents the database file, the dataAdapters are the intermediate
'link' to each table and the DataTables are the database tables held in
VB memory?
so I should modify the DataTables and when done save them using the
DataAdapter Update command to save them? (e.g.
daDataAdapterCustomer.Update(dtCustomer)
Yes and no. The dataadapter is to get and update the part of the datatable
as you have told you want. Important to know is that it is not a continious
link. It is everytime a one time action. That in opposite of AdoDB.

For the rest take the advice from Armin about the AdoNet group for this kind
of questions.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top