Tuesday, July 20, 2010

Connecting to MS Access DataBase using QTP

Dim rs,con
set con = createobject("adodb.connection")
set rs = createobject("adodb.recordset")
con.provider = "microsoft.jet.oledb.4.0"
con.open "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb"
rs.open "select * from Orders where Flight_Number=4219 ",con

'to know the number of orders in class1
'rs.open "select count(*) from Orders group by class",con

'to insert into database
rs.open "insert into emp(empno,empname,empsal) values (4,'lakshmi',400),con

'display each field in the record set
Do while not rs.eof
For Each Field In rs.Fields
MsgBox Field.name
MsgBox Field.value
Next
rs.MoveNext

Loop

' Close the connection.
con.Close

1 comment:

  1. It is really a great work and the way in which u r sharing the knowledge is excellent.
    Thanks for helping me to understand basic concepts. As a beginner in software testing your post help me a lot.Thanks for your informative article. software testing Training in chennai | Best software testing Training institute in velachery

    ReplyDelete