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 analyzing the checpoint results?
Is there any pdf or online book for QTP Scripting? Let me know more about QTP Scripting.
How can you exit from an action?
can any body give the banking domain concepts/links
hi guys we r working in office...we write some scripts..suddenly we have a work(5min only) in out side..what will do now,,,used to system shut down or log off or lock or sleep mode,switch use or hibernate?
How will you handle java tree in qtp?
What is the differences between image check point and bit map check point?
What are the main differences of qtp and win runner?
what is vmodel?advantages and disadvantages of vmodel?
What is file database?
Explain advantages and disadvantages of ddf?
What is the difference between a Function and Action in QTP?
If a button named "CLICK" is recorded in low level recording mode , what will be the values stored for "name" property of that button in object repository ?
Give me At Least 5 Differences between DOCUMENTATION OBJECT MODEL(DOM)and COMPONENT OBJECT MODEL(COM)? Interviewer said me to WRITE the difference only in points not as you WRITE a paragraph ???? only in points
How to import a test case present in ".xls" file to TD under a Test set?