SIGN UP MEMBER LOGIN:    
ARTICLE

DataAdapter Properties and Methods in ADO.NET

Posted by Mahesh Chand Articles | ADO.NET in C# January 06, 2010
In this article I will explain about DataAdapter Properties and Methods in ADO.NET.
Reader Level:

This article has been excerpted from book "A Programmer's Guide to ADO.NET in C#".

DataAdapter Properties

As 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

PROPERTY

EXAMPLE

SelectCommand

cmd.SelectCommand.CommandText = "SELECT * FROM Orders ORDER BY Price";

DeleteCommand

TheDataSetCommand.DeleteCommand.CommandText = "DELETE FROM orders WHERE LastName = 'Smith' ";

InsertCommand

TheDataSetCommand.InsertCommand.CommandText = "INSERT INTO Orders VALUE (25, 'Widget1', 'smith')";

UpdateCommand

TheDataSetCommand.UpdateCommand.CommandText = "UPDATE Orders SET ZipCode = '34956' WHERE OrderNum = 14";

Data Adapter Methods

The 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

DESCRIPTION

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.

Conclusion

Hope 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.

adobook.jpg This essential guide to Microsoft's ADO.NET overviews C#, then leads you toward deeper understanding of ADO.NET.

Login to add your contents and source code to this article
share this article :
post comment
 

Thanks. This is really helpful. http://www.xininvoice.com

Posted by keith chee Jan 11, 2011
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Gauge for SharePoint
Become a Sponsor