Creating an ADO.NET Connection object

Before you establish a connection, create an instance of a .NET data provider’s Connection object and set its properties. The example shown here uses the .NET Framework Data Provider for OLE DB:

[Visual Basic]
Dim connString As New String _
("User ID=dba;Password=sql;Data Source=EAS Demo DB V105 DWD;Provider=ASAProv.90")
Dim oleDbConn As New OleDbConnection(connString)

[C#]
OleDb.OleDbConnection oleDbConn = new OleDb.OleDbConnection();
oleDbConn.ConnectionString = "User ID=dba;
Password=sql;Data Source=EAS Demo DB V105 DWD;
Provider=ASAProv.90";

When an instance of a connection has been created, it can be used again. Note that the ConnectionString property cannot be updated after the connection has been opened.