|
-
May 14th, 2013, 04:31 AM
#1
Thread Starter
Addicted Member
[RESOLVED] DGV+ binding source( table filled with OleDBDataAdapter) - call adapter Command
Hi!
Today I learned about the possibility to set the UpdateCommand, InsertCommand and DeleteCommand on the OleDbDataAdapter which I use to fill the datatable which through a binding source displays data in my DataGridView.
Now I wonder, and cannot find an answer. Do I have to call those methods manually, or are they bound to some internal event handlers?
Kind regards,
Andy
Before you ask for any code, here are the main parts:
Code:
myOleDBCommand.Connection = newConn
myOleDBCommand.CommandText = sSQL 'SELECT statment string
Dim dataAdapter As New OleDbDataAdapter(myOleDBCommand)
Dim myTab As New DataTable()
Dim insertCommand As OleDbCommand
insertCommand = New OleDbCommand("INSERT ...")
dataAdapter.InsertCommand = insertCommand
dataAdapter.Fill(myTab)
myGrid2BindingSource.DataSource = myTab
myGrid2.DataSource = myGrid2BindingSource
Last edited by AndyLD; May 14th, 2013 at 04:40 AM.
-
May 14th, 2013, 05:11 AM
#2
Re: DGV+ binding source( table filled with OleDBDataAdapter) - call adapter Command
Neither. When you call Fill on the adapter it executes the SelectCommand to retrieve data from the database into the DataTable. To save changes you call Update and it executes the InsertCommand, UpdateCommand and DeletedCommand as required to save rows that have been Added, Modified and Deleted respectively. You might follow the CodeBank link in my signature and check out my thread on Retrieving & Saving Data for an example.
-
May 14th, 2013, 05:39 AM
#3
Thread Starter
Addicted Member
Re: DGV+ binding source( table filled with OleDBDataAdapter) - call adapter Command
Dear Jmcilhinney,
thank you very much. Now it's clear. So I have to select the right event when to call the OleDbDataAdaper.Update() method.
P.S. I opened your codebank thread and searched for "Retrieving & Saving Data", why doesn't this search match also "Retrieving and Saving Data" string ?
Last edited by AndyLD; May 14th, 2013 at 05:53 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|