O'Reilly logo

Sams Teach Yourself ADO.NET in 24 Hours by Paul Bertucci, Jason Lefebvre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required