Initializes a new instance of the SQLConnection class when given a server, a password, an user ID, and a database to connect to.
[Visual Basic] Overloads Public Sub New( _ ByVal dataSource As String, _ ByVal userID As String, _ ByVal password As String, _ ByVal database As String _ ) [C#] public SQLConnection( string dataSource, string userID, string password, string database ); [C++] public: SQLConnection( String* dataSource, String* userID, String* password, String* database ); [JScript] public function SQLConnection( dataSource : String, userID : String, password : String, database : String );
Exception Type | Condition |
---|---|
Exception | The connection could not be mapped properly.
-or- An improper argument was passed or an argument was missing. |
When an instance of SQLConnection is created, the following read/write properties are set to initial values.
Properties | Initial Value |
---|---|
ConnectionString | empty string ("") |
ConnectionTimeout | 15 |
Database | database |
IsolationLevel | Unspecified |
DataSource | dataSource |
UserID | userID |
Password | password |
You can change the value for any of these properties through a separate call to the property.
The following example creates a SQLConnection and sets some of its properties.
SQLConnection Class | SQLConnection Members | System.Data.SQL Namespace | SQLConnection Constructor Overload List