From: John on 27 Feb 2010 21:52 Hi I have a winform app with form control bound to a binding source TblClientsBindingSource. The binding source has a data table as its data source as per below code; dAdapter = New OleDbDataAdapter("SELECT * FROM tblClients WHERE ...", Conn) dAdapter.Fill(dTable) TblClientsBindingSource.DataSource = dTable My question is; how do I delete the record currently pointed to by the binding source from the backend database table tblClients? Thanks Regards
From: Mr. Arnold on 27 Feb 2010 22:22 John wrote: > Hi > > I have a winform app with form control bound to a binding source > TblClientsBindingSource. The binding source has a data table as its data > source as per below code; > > dAdapter = New OleDbDataAdapter("SELECT * FROM tblClients WHERE ...", Conn) > dAdapter.Fill(dTable) > TblClientsBindingSource.DataSource = dTable > > My question is; how do I delete the record currently pointed to by the > binding source from the backend database table tblClients? > > Thanks > > Regards > It must be bound to some control. The control is bound on a DataMemeberValue from the bound source, which would have the record's key. You need to get the key to the record from the control that's bound to the bounding source. If the binding control is like a DataGridView, then you would select the record in the DataGridView on SelectedIndexChanged event of the control using SlectedValue that has the key to the record to delete. You would have a Delete button with a buton click event that will take the SelectedValue and go back to the database with some routine to delete the row out of the table by key. The button click event would have code in it to do your binding source and bind the source to the control again. The record is deleted, you get the data from the table again, the record is not there now, and you bind the new data to the control.
From: Cor Ligthert[MVP] on 28 Feb 2010 02:55 Don't use dTable but dTable.DefaultView To that you can add a rowfilter dTable.DefaultView.rowfilter = "CustomersName = John" The Class type of the DefaultView is DataView Success "John" <info(a)nospam.infovis.co.uk> wrote in message news:u7v$NECuKHA.4220(a)TK2MSFTNGP05.phx.gbl... > Hi > > I have a winform app with form control bound to a binding source > TblClientsBindingSource. The binding source has a data table as its data > source as per below code; > > dAdapter = New OleDbDataAdapter("SELECT * FROM tblClients WHERE ...", > Conn) > dAdapter.Fill(dTable) > TblClientsBindingSource.DataSource = dTable > > My question is; how do I delete the record currently pointed to by the > binding source from the backend database table tblClients? > > Thanks > > Regards > > > >
|
Pages: 1 Prev: User defined events Next: Concurrency violation handling in data adapter |