Need confirmation on Adapter object ??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

I just would like confirmation or infirmation on the following topics.
When using an SQLAdapter in the folloing way:

m_dsAdapter = New SqlClient.SqlDataAdapter
m_dsReel = New DataSet
m_dsAdapter.Fill(m_dsReel)

The m_dsReel dataset is populated by the Fill method of the Adapter, then
the conection to the database is closed.

After modifying some records and in order to apply those recordback to the
database we call the Update method that will execute the proper UPDATE,
INSERT or DELETE method based on the row status of the dataset.

So far so good.

The question is : Does the DataAdapter.Update method will automatically
applyied to the dataset it has previously filled ?
In orther words, dos the created Adapter object is linked to the dataset
object that has been filled ?

I ask you that becasue I have read somewhere that in case you work with
multiple table, it is recommand to use one Adapter and datset object by
tables , is it reaaly the case ? if not why people say that ?

thnaks fro your answer
regards
serge
 
serge calderara said:
Dear all,

I just would like confirmation or infirmation on the following topics.
When using an SQLAdapter in the folloing way:

m_dsAdapter = New SqlClient.SqlDataAdapter
m_dsReel = New DataSet
m_dsAdapter.Fill(m_dsReel)

The m_dsReel dataset is populated by the Fill method of the Adapter, then
the conection to the database is closed.

After modifying some records and in order to apply those recordback to the
database we call the Update method that will execute the proper UPDATE,
INSERT or DELETE method based on the row status of the dataset.

So far so good.

The question is : Does the DataAdapter.Update method will automatically
applyied to the dataset it has previously filled ?

No. You have to pass an instance of dataset or datatable to Update method.
In orther words, dos the created Adapter object is linked to the dataset
object that has been filled ?

DataAdapter is not linked to anything. It might know how to save a table
regardless of how the table was created or populated.
I ask you that becasue I have read somewhere that in case you work with
multiple table, it is recommand to use one Adapter and datset object by
tables , is it reaaly the case ? if not why people say that ?

One dataadapter can update one table at a time. Thus if you have a dataset
with two tables you will need two dataadapters.
 
Thanks for your reply.

What will happen then if we use :
m_dsAdapter.Update(ds_myDAtaset)

and ds_myDataSet containes 2 tables ?
Does only the Table(0) will be updated ?
 
Back
Top