Different ways of opening an ADO DSN less connection and recordset.
Posted on August 5, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 'Database - Different ways of opening an ADO DSN less connection and recordset. 'Using the ActiveConnection and Source properties to open ADO recordset. Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Set conn = New ADODB.Connection Set rst = New ADODB.Recordset conn.Provider = "Microsoft Jet 4.0 OLE DB Provider" conn.ConnectionString = "Data Source=" & Server.Mappath("\PATH\mydatabase.mdb") conn.Open rst.Source = "Select * From Customers Where CustID = 23" rst.ActiveConnection = conn rst.Open '------------------------------------------------------- 'Open a ADO DSN less connection and recordset by passing all arguments to the Open method of the recordset object Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Set conn = New ADODB.Connection Set rst = New ADODB.Recordset conn.Provider = "Microsoft Jet 4.0 OLE DB Provider" conn.ConnectionString = "Data Source=" & Server.Mappath("\PATH\mydatabase.mdb") conn.Open rst.Open "Select * From Customers Where CustID = 23", conn |