System.Data Namespace IDbConnection Class
Sets or retrieves the string used to connect to a database.
Script |
IDbConnection.ConnectionString [ = connectString ] |
connectString |
A string that contains the connection settings. |
The property is read/write with no default value.
Exception Type |
Condition |
ArgumentException |
Occurs when an invalid connection string argument has been supplied or a required connection string argument has not been supplied. |
The ConnectionString property can only be set while the connection is closed.
The following example instantiates an IDbConnection, sets some of its parameters in the connection string, and opens the connection.
SqlConnection myConn = new SqlConnection ( );
myConn.ConnectionString = "user id=sa; password=yervzeñun;" +
"data source=myServer; initial catalog=northwind;"
myConn.Open ( );
Dim myConn As New SqlConnection ( )
myConn.ConnectionString = "user id=sa; password=yervzeñun;" &_
"data source=myServer; initial catalog=northwind;"
myConn.Open ( ) |
|
C# |
VB |
IDbConnection Members ConnectionTimeout Database Connecting to a Database