How to connect to the Database from QTP?
Answer Posted / ss
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 = "Select NAME from dbo.EMPLOYEE where AGE = 29"
'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
Value = objRecordSet.fields.item(0)
msgbox Value
' Release the Resources
objRecordSet.Close
objConnection.Close
Set objConnection = Nothing
Set objRecordSet = Nothing
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How to record application running on the Virtual machine?
How to use Environment parameterization? Explain with an example.
How to perform cross platform testing and cross browser testing using qtp? Can you explain giving some example?
Where to use Property Let, Property Get, Property Set in UFT
can i compare two databases using QTP ?
Can anybody let me know how to test the Drag and drop feature of the column in a .net application...eg..i hav to test the drag and drog feature of a table(swftable) in a application..plze help!!
Explain the views in the QTP GUI?
What is quicktest professional window?
When QTP object wait time is 10 seconds, and in test script wait time is 5 seconds and in function library wait time is 2 seconds how much time does the wait occur? or which is given priority.
How to use output values in qtp ?
Hello, Is there any way to send the test results in html format (or any other) by email using outlook after the test run ends? thank you in advance
What are the ordinal identifiers in web page?
Can we call qtp test from another test using scripting. Suppose there are 4 tests and I want to call these tests in a main script. Is this possible in qtp?
Define Error Pane of UFT?
What is the file extension of the code file in qtp?