How to retrieve data from database using QTP? - TestingQ.com

-->Exclusive Portal for Testing Jobs

How to retrieve data from database using QTP?

Dim objConnection 
 'Set Adodb Connection Object
 Set objConnection = CreateObject("ADODB.Connection")     
 Dim objRecordSet 

 'Create RecordSet Object
 Set objRecordSet = CreateObject("ADODB.Recordset")     

 Dim DBQuery 'Query to be Executed
 DBQuery = "Query to be Executed"

 'Connecting using SQL OLEDB Driver
 objConnection.Open "Provider=sqloledb.1;Server=.\SQLEXPRESS;User Id=sa;Password=Password123;Database=Trial"

 'Execute the Query
 objRecordSet.Open DBQuery,objConnection

 'Return the Result Set
If (not objRecordSet.EOF) then
For i = 0 To ObjRecordSet.Fields.Count - 1
  Value = objRecordSet.fields(i)
'Value = objRecordSet.fields.item(i)

  msgbox Value
Next 
End If

 ' Release the Resources
 objRecordSet.Close        
 objConnection.Close

 Set objConnection = Nothing
 Set objRecordSet = Nothing



To receive daily posted JOBS & Interview Questions
Just enter your email address below and click 'Submit'
Enter your email address:

Make sure to activate your subscription by clicking on the activation link sent to your email