Providing ADO.NET Connection Information

In order to create a connection to a data source, you'll need to supply a string containing a series of name/value pairs, providing the information that ADO.NET requires in order to locate and use the data. For example, if you want to connect to a SQL Server database using the System.Data.OleDb namespace, you might use a connection string like this:

Provider=sqloledb;Data Source=(local);
Initial Catalog=Northwind;User ID=sa;Password=;

Alternatively, to connect to a Microsoft Access (Jet) database, you might use a connection string like this:

Provider=Microsoft.Jet.OleDb.4.0;
Data Source=C:\Northwind.mdb

If you're using SQL Server with integrated security, you won't want to pass in the user ID and password ...

Get ASP.NET Developer's JumpStart 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.