The Command Object

The Command object enables you to execute queries against your data source. However, in order to retrieve data, you must know the schema of your database as well as how to build a valid SQL query. In Hour 3, you learned how to build SQL queries to retrieve and modify data. You will now have the opportunity to apply that knowledge as you use the Command object.

The SqlCommand object must be used in conjunction with the SqlConnection object. If you attempt to attach a SqlCommand to an OleDbConnection, you will get an error from the compiler. The converse is also true: OleDbCommands cannot be used with the SqlConnection.

Associating ...

Get Sams Teach Yourself ADO.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.