Friday, October 17, 2014

QTP: MS Access Connectivity

Option Explicit
Dim objConn,objRS
 
Set objConn = CreateObject("ADODB.Connection") 
Set objRS = Createobject("ADODB.Recordset")

objConn.Open "Driver={Microsoft Access Driver (*.mdb),(*.accdb)};DBQ=C:\USERS\Desktop\FileName.accdb;"

objRS.Open "Select * FROM TABLE1", objConn

Do while not objRS.EOF
 Browser("Gmail").WebEdit("username").Set objRS.FIELDS("UN")
 Browser("Gmail").WebEdit("password").Set objRS.FIELDS("PW")
 Browser("Gmail").WebBotton("LogIn").CLICK
 objRS.MOVENEXT
Loop

'Release created objects
Set objRS= NOTHING
Set objConn= NOTHING


Note: The database we are using here is MS Access 2007(*.accdb). Create a table in MS Acess 2007 called "TABLE1" and column 'names as "UN" and "PW" and path of the table which we create is C:\USERS\Desktop\FileName.accdb. 

No comments:

Post a Comment