vb.net / ado.net design question
Quote:
> I am not clear on the best way to design data access for a desktop app
with
> dot net and ado.net. I am using disconected recordset, connecting to an
> offsite server over the internet.
Disconnected recordset? No such thing in ADO.NET. Are you sure you are not
using ADO?
Quote:
> If my project opens 15 tables and updates all 15 of them, is the
> correct way to have 15 different data adapters that I keep until I update
> the tables, or is there a better way ?
Data adapters are only used to fill tables. They can be disposed after
filling the table. When you go to save the DataSet, you can then build your
Command objects and add the SQL for updates. My practice is to store the
connection string and the SELECT SQL in the Extended properties of the
DataTable. I can add other things to the tables, such as INSERT, UPDATE,
and DELETE SQL, and SqlClient Parameter arrays that allows me to pass in a
DataSet to a middleware method, which then saves the table changes in the
order I specify. It is a big timesaver to create a DLL that can create a
DataSet and update it. Saves writing a lot of code over and over.
Quote:
> With VB6 and ADO, when I wanted to update the record set I could just do:
> Set rs.ActiveConnection = conn
> rs.UpdateBatch
You can still do pretty much the same in ADO.NET. ADO.NET just gives more
control over what ADO and VB6 did.
Quote:
> All I needed was the connection string and the record set. I could put
this
> all in one simple function, and just pass the record set and connection
> string to the function and that was that.
I pass a DataSet to a function and it saves the changes.
Quote:
> But with vb dot net and ado.net it seems like you need a data adapter for
> each data set. It is not all that terrible to keep track of both a
> dataadapter and a dataset, but I am wondering if I am missing some
important
> concept or design technique.
Using a dataadapter for each table is a good idea, but they do not have
exist after filling the table.
Quote:
> I am using a dataset for each record set. Not sure if this is the best way
> to do it either.
A DataSet can hold multiple Datatables. Good practice is to have your
Datatables mirror the tables in the database, and use DataRelations to
related tables together. Much like DataShaping in ADO.
Jeff Jones