When connection is established ADO Recordset Object is to able to read database data, the data must first be loaded into a recordset.
The ADO Recordset object is used to hold a set of data from a database table.
Create an ADO Table Recordset
After making the connection to data of database through ADO Database Connection,it is possible to create an ADO Recordset.
For Example: we have a database named "vyom", we can get access to the "Employee" table inside the database with the following lines:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "e:/vyomworld/vyom.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Employee", conn
%>
Create an ADO SQL Recordset
To create the recordset, use the following line:
<%
Set rs=Server.CreateObject("ADODB.Recordset")
%>
We can also get access to the data in the "Emloyee" table using SQL:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/vyomworld/vyom.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Employee", conn
%>
Extract Data from the Recordset:
When recordset is opened, we can extract or access the data from recordset.
For Example: we have a database named "vyom", we can get access to the "Employee" table inside the database with the following lines:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/vyomworld/vyom.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Employee", conn
for each x in rs.fields
response.write(x.name)
response.write(" = ")
response.write(x.value)
next
%>
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.