This article has been excerpted from book "A Programmer's Guide to ADO.NET in C#".DataAdapter PropertiesAs you start working data adapters, you need take a Quick looks at data adapter properties and methods. The DataAdapter has properties of type Command, which represent the ways it can query, insert, delete, and update the database. These properties are of type OleDbCommand.Table 5-28 describes OleDbDataAdapter class properties.Table 5-28 describes ole Db DataAdapter properties
PROPERTY
DESCRIPTION
DeleteCommand
Represents a DELETE statement or stored procedure for deleting records from the data source
InsertCommand
Represents an INSERT statement or stored procedure for inserting a new record to The data source
SelectCommand
Represents a SELECT statement or stored procedure can be used to select records from a data source
UpdateCommand
Represents an UPDATE statement or stored procedure for Updating recording in a data source
TableMappings
Represents a collection of mappings between actual data source table and a DataTable object
Table 5-29 shows these command properties and their examples.Table 5-29. OleDbDataAdapter Command Properties with Examples
EXAMPLE
cmd.SelectCommand.CommandText = "SELECT * FROM Orders ORDER BY Price";
TheDataSetCommand.DeleteCommand.CommandText = "DELETE FROM orders WHERE LastName = 'Smith' ";
TheDataSetCommand.InsertCommand.CommandText = "INSERT INTO Orders VALUE (25, 'Widget1', 'smith')";
TheDataSetCommand.UpdateCommand.CommandText = "UPDATE Orders SET ZipCode = '34956' WHERE OrderNum = 14";
Data Adapter MethodsThe DataAdapter class provides many useful methods. For instance, the FILL method of the DataAdapter fills data from a data adapter to the DataSet object, and the Update method stores data from a DataSet object to the data source.Table 5-30. The ole Db Data Adapter methods
METHOD
Fill
This method fills data records from a DataAdapter to a DataSet object.
FillSchema
This method adds a DataTable to a DataSet.
GetFillParameters
This method retrieves parameters that are used when a SELECT statement is executed.
Update
This method stores data from a data set to the data source.
ConclusionHope this article would have helped you in understanding DataAdapter Properties and Methods in ADO.NET. See my other articles on the website on ADO.NET.