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

Connecting to Various Data Sources

It would be impossible to include code to connect to all the possible kinds of databases. The next section shows you how to connect to Microsoft SQL Server versions 7.0 and up using the managed SQL provider in the System.Data.SqlClient namespace and also how to connect to various OLE DB data sources using the System.Data.OleDb namespace.

SQL Server

When using the managed SQL provider, do not specify the Provider keyword in your connection string. In fact, the only connection string properties you're likely to need are the ones in Table 5.1.

Table 5.1. SQL Connection String Options
Connection String Property Description
Initial Catalog Specifies the database you're connecting to
Server Specifies the server you're ...

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