|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need confirmation on Adapter object ??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
Show quote
"serge calderara" <sergecalder***@discussions.microsoft.com> wrote in No. You have to pass an instance of dataset or datatable to Update method.message news:2A80AFBA-267C-4DAF-8BA8-10F6594A0E0A@microsoft.com... > 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 DataAdapter is not linked to anything. It might know how to save a table > object that has been filled ? regardless of how the table was created or populated. > One dataadapter can update one table at a time. Thus if you have a dataset > 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 ? with two tables you will need two dataadapters. -- Miha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ 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 ? Show quote "Miha Markic [MVP C#]" wrote: > > "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in > message news:2A80AFBA-267C-4DAF-8BA8-10F6594A0E0A@microsoft.com... > > 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. > > -- > Miha Markic [MVP C#] > RightHand .NET consulting & development www.rthand.com > Blog: http://cs.rthand.com/blogs/blog_with_righthand/ > > > |
|||||||||||||||||||||||