Professional Documents
Culture Documents
The ADO Recordset object is used to hold a set of records from a database table.To be
able to read database data, the data should be loaded into a recordset.
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
Note: The database we are using here is MS Access.Before running this script create a table in
MS Acess.In the above script I used table called "emp" and column 'names as "v1" and "v2".
"d:testdata.mdb" is path of the table which we created. The main use of this script is to use
testdata of table(which is in ' database) in the application. In the above script we are passing
values from database to Textboxes in Windows Application.
⇒QTP Script for connecting to sqlserver:
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.open"Driver={SQL
Server};server=MySqlServer;uid=MyUserName;pwd=MyPassword;database=pubs"
rs.open "select * from emp",con
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
'Release objects
Set rs= nothing
Set con= nothing
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
'Release objects
Set rs= nothing
Set con= nothing
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
Msgbox rs(0)
'Release objects
Set rs= nothing
Set con= nothing
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")