Home All Groups Group Topic Archive Search About

DataGrid How to delete underlying database

Author
31 Mar 2005 12:58 AM
Tom McL.
I have a datagrid bound to a database and
I would like to be able to select a row
programmable and then delete it.
I have been trying to use the OleDbDataAdapter1.DeleteCommand
but I can't figure out the syntax.

DataGrid1.Select(DataGrid1.CurrentRowIndex)
OleDbDataAdapter1.DeleteCommand   ???????????

Author
31 Mar 2005 6:37 AM
Daniel Ch. Bloch
First of all: You're using the oledb dataadapter, so the delete syntax
depends on the underlying database you use.

The DeleteCommand is used within the dataadapter.Update method. I think you
cannot use it all alone (but I'm not quite sure).

So, the simplest way for you is to use the dataadapter wizard of Visual
Studio that will create you all of the commands used to.

After that, you can manually delete the row in your datasource (a datatable
normalliy) and the make a dataadapter.update.

Daniel


Show quoteHide quote
"Tom McL." wrote:

> I have a datagrid bound to a database and
> I would like to be able to select a row
> programmable and then delete it.
> I have been trying to use the OleDbDataAdapter1.DeleteCommand
> but I can't figure out the syntax.
>
> DataGrid1.Select(DataGrid1.CurrentRowIndex)
> OleDbDataAdapter1.DeleteCommand   ???????????
>
>
>
>