Dataadapter DeleteCommand - OLEDB Data Source
The OleDbDataAdapter is a component of the ADO.NET Data Provider that facilitates data access and manipulation. It plays a crucial role in enabling a disconnected data retrieval mechanism in conjunction with the DataSet object. By using the OleDbDataAdapter, we can efficiently retrieve and manipulate data from a data source.
In addition to its data retrieval capabilities, the OleDbDataAdapter also provides the InsertCommand, UpdateCommand, and DeleteCommand properties. These properties represent Command objects that are responsible for managing updates to the specified data source based on modifications made to the DataSet.
To illustrate the usage of the DeleteCommand property, let's consider the following source code example:Full Source VB.NET
In the above code, we first establish a connection to the database using the provided connection string. We define the select query to retrieve data from the table, as well as the delete query to remove a row from the table based on the ID column. We create an OleDbDataAdapter and set its SelectCommand to the select query.
Next, we create an OleDbCommand for the delete operation and assign it to the DeleteCommand property of the OleDbDataAdapter. We add a parameter to the delete command to specify the ID value for deletion.
To perform the deletion, we populate a DataSet with data from the database using the Fill method of the OleDbDataAdapter. We can then make modifications to the data in the DataSet, such as removing a row.