O'Reilly logo

Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition by David Sceppa

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

Using the SqlConnection as a Starting Point

Once you’ve connected to your SQL Server database, the SqlConnection object can serve as the starting point for a number of operations—creating commands, starting transactions, and retrieving schema.

Creating SqlCommands

The SqlCommand class, which We’ll explore in Chapter 4, is the class you use to execute queries against your database. To execute a query, you must set the SqlCommand object’s Connection property to a SqlConnection object. The SqlConnection class provides a CreateCommand method that you can use to simplify the process. This method returns a new SqlCommand object that’s already initialized to use your SqlConnection object.

One benefit to the CreateCommand method is that it’s available on ...

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