System.Data.SqlClient Namespace SqlConnection Class
Initializes a new instance of the SqlConnection class.
1. Initializes a new instance of the SqlConnection class.
2. Initializes a new instance of the SqlConnection class with the specified ConnectionString.
The following example initializes and opens an SqlConnection with the given connection string.
NOTE: This example uses one of the overloaded versions of the SqlConnection constructor. For other examples that may be available, see the individual overload topics.
string connString = "user id=sa; password=yervzeñun;" +
"initial catalog=northwind; data source=myServer";
SqlConnection myConn = new SqlConnection ( connString );
myConn.Open ( );
Dim connString As String = "user id=sa; password=yervzeñun;" &_
"initial catalog=northwind; data source=myServer"
Dim myConn As New SqlConnection ( connString )
myConn.Open ( ) |
|
C# |
VB |
SqlConnection Members ConnectionString Connecting to a Database