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 ...
Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition 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.