Connecting to a Database

In ADO.NET, as in many object-based data-access APIs, you use a connection object to establish a connection with a database. In the ADO.NET SQL Server provider, the object is called SqlConnection; in the OLE DB provider, it's cleverly called OleDbConnection. Both objects are conceptually identical, although their implementation details differ slightly. The main difference between the two objects has to do with the syntax of the connection string. The connection string is required to tell the object how to get to the database that you're interested in.

NOTE

The SqlConnection class is a member of the System.Data.SqlClient namespace. The OleDbConnection class is a member of System.Data.OleDb namespace. A full list of members ...

Get C#® Developer's Guide to ASP.NET, XML, and ADO.NET 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.