Connection Strings

The previous code snippets have involved setting the ConnectionString property on SqlConnection objects through that class’s constructor. However, we’ve yet to discuss what a connection string is.

What Is a Connection String?

In the previous code snippets, we supplied a connection string for our new SqlConnection objects. A connection string consists of a series of name-value pairs delimited by semicolons:

strConn = "Setting1=Value1;Setting2=Value2;..."

The settings and values depend on the data source you want to connect to, as well as on the technology you’re using to connect to your data source.

The SQL Client .NET Data Provider is extremely flexible when it comes to connecting to databases, and it provides a variety of ways to ...

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.