Taking Command in ADO.NET

This article has been excerpted from the book "A Programmer's Guide to ADO.NET in C#".
 
If you've ever written database applications using ODBC, DAO, or ADO, you must be familiar with the concept of manipulating data through recordsets or executing direct SQL queries. For example, in DAO and ODBC, you can use either the Execute method of a Database object to execute direct SQL commands or use a recordset to manipulate data by navigating through records one by one.
 
The Command object allows data to directly execute SQL statements such as INSERT, SELECT, UPDATE, and DELETE against a data source for reading, writing, and updating a database. You can also use the Command object to execute stored procedures. The SqlCommand, OleDbCommand, and OdbcCommand Classes represent the Command objects in SQL, OleDb, and ODBC data providers, respectively. All of the data provider-specific command classes implement the IDbCommand interface, which implements basic functionality for these classes. Figure 5-29 shows the relationship between IDbCommand and the data provider-specific command classes.
 
IDbconnection.gif
 
Figure 5-29. Data Provider-specific classes implementing IDb Command
 
Table 5-24 lists some of the more implement properties of the Command class for the OleDb data provider. The CommandText listed in this table can contain either a SQL statement or a stored procedure name. The CommandType determines which one of these forms the Command text takes on.
 
Table 5-24. OleDb Command Properties
 
PROPERTY
DESCRIPTION
CommandText
Could be a SQL statement, a stored procedure, or a database table name depending On the CommandType
CommandType
An enumeration of value Text, StoredProcedure, or TableDirect
Connection
An OleDbConnection representing the ActionConnection
 

Conclusion

 
Hope this article would have helped you in understanding Taking Command 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 a deeper understanding of ADO.NET.