We will be using ActiveX Data Objects (ADO) to create a connection to Access database. ADO model contains six objects and we will be using Connection String to connect to database.
Creating a Connection String using ADO and opening the connection
To connect to Access database we can create a connection object by using ADO. Here is an example of connection object creation and opening the connection object.
Note that here we have using server MapPath to locate the access database. Here database is stored inside db directory relative to the script running this code. Now we have opened the connection to the access database next is we need one object to handle records.
To handle records of a MS access table we need recordset object provided by ADO. Using this object we can get a subset of records of our table. We can declare Record set object like this.
Set objRs = Server.CreateObject("ADODB.Recordset")
By just declaring the recordset object we can't handle data, we need to open it and during the opening process we can give different arguments to handle the recordset object. Here is the syntax of opening a Recordset object.