.NET Framework Data Provider for SQL Server

This .NET Framework Class Library is provided by Microsoft.
The class library is contained in the file System.Data.dll.
Add a reference to the assembly System.Data and include the System.Data.SqlClient namespace. Instantiate a new SqlConnection connection object. Set the connection string and open the connection.

VB.NET code sample
Imports System.Data.SqlClient
Dim myConnection As SqlConnection = New SqlConnection()
myConnection.ConnectionString = myConnectionString
' execute queries, etc

C# code sample
using System.Data.SqlClient;
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = myConnectionString;
// execute queries, etc

The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. It is lightweight and performs well because it is optimized to access a SQL Server directly without adding an OLE DB or Open Database Connectivity (ODBC) layer.

This is the number one to use if you want your .NET application or website to connect to an SQL Server.

A SqlConnection object represents a unique session to a SQL Server data source. With a client/server database system, it is equivalent to a network connection to the server. SqlConnection is used together with SqlDataAdapter and SqlCommand to increase performance when connecting to a Microsoft SQL Server database.

When you create an instance of SqlConnection, all properties are set to their initial values.

If the SqlConnection goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling Close or Dispose. Close and Dispose are functionally equivalent. If the connection pooling value Pooling is set to true or yes, the underlying connection is returned back to the connection pool. On the other hand, if Pooling is set to false or no, the underlying connection to the server is actually closed.

To ensure that connections are always closed, open the connection inside of a using block. Doing so ensures that the connection is automatically closed when the code exits the block.
More info about this class library can be found at the Microsoft product page.
Download link missing
The .NET Framework Data Provider for SQL Server installation package download link is missing. Please provide info and contribute to the community by email to
Connection Strings
The .NET Framework Data Provider for SQL Server class library can be used to connect to the following data sources:

SQL Azure SQL Server 2000, 7.0 SQL Server 2005 SQL Server 2008 SQL Server 2012
To see available connection options, navigate connection strings reference by the above data source links.
Additional info or comments on this class library? Want to submit content?


Copyright © 2013 30c.org   |   All Rights Reserved   |   Powered by CSAS   |   Send feedback, articles, requests and more connection strings here.