Connect to Microsoft Access database in QTP
Here are the steps to connect to microsoft access database in QTP.
'Declare the variables
Dim MyConn, SQL_query,ResultSet,myName
'Open database connection
Set MyConn = CreateObject("ADODB.Connection")
MyConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\temp\winrunner_db.mdb"
'Define the SQL query
SQL_query = "SELECT Name FROM Employee"
'Execute the query and store results in ResultSet
Set ResultSet = MyConn.Execute(SQL_query)
ResultSet.MoveFirst
'Read results from ResultSet in a loop
While NOT ResultSet.EOF
Set name1 = ResultSet("name")
ResultSet.MoveNext
WEND
'Release resources
ResultSet.close
MyConn.close
'Declare the variables
Dim MyConn, SQL_query,ResultSet,myName
'Open database connection
Set MyConn = CreateObject("ADODB.Connection")
MyConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\temp\winrunner_db.mdb"
'Define the SQL query
SQL_query = "SELECT Name FROM Employee"
'Execute the query and store results in ResultSet
Set ResultSet = MyConn.Execute(SQL_query)
ResultSet.MoveFirst
'Read results from ResultSet in a loop
While NOT ResultSet.EOF
Set name1 = ResultSet("name")
ResultSet.MoveNext
WEND
'Release resources
ResultSet.close
MyConn.close