Home > How-To Library > Database
Different ways of opening an ADO DSN less connection and recordset.
**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * **************************************************************** '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
If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.