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 many tabs are available in debug viewer pane?
What are the different types of checkpoints?
How can you close the second opened browser?
What is different command used in command Prompt while using QTP?
if anyone has idea of the interview procedure in covansys, plz send me a mail?
Explain the N-tire structure(process) for Funds Transfer ( means give N ways to funds Transfer in an Application)
tell me abt a time when u had to go above &beyind the call of duty to get the job done
What is 'sleep' in sync point?
Hi, I have 2 dropdown listboxes called region and city/area. It needs to select one region(Santa Clara) and one city/Area (Sunnyvale).So I put this in the for loop and I am storing the Items in the variable called itemname. The regions value will get changed,so I used reg expression for this regions. This is my code Browser("MLSListings.com").Page("MLSListings.com").Link("ยป County/Area").Click Browser("MLSListings.com").Page("MLSListings.com").WebList ("regions").Check CheckPoint("regions") ListSize=Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").GetTOProperty("items count") For i = 1 To ListSize-1 Itemname =Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").GetItem(i+1) Browser("MLSListings.com").Page("MLSListings.com").WebList ("regions").Select Itemname ................. If I run the script,I am getting the following error, Cannot identify the specified item of the regions object. Confirm that the specified item is included in the object's item collection. Any Help? Thank you, Uma
I have many listboxes in my application. I have to check whether the contents inside the listboxes are in sorted order or not..can anyone please send the code as early as possible
How do you open adobe acrobat file in QTP and do some testing on that file ?
In qtp, explain what is crypt object
Hi! My OTP script has several bitmap checkpoints included which I check in the test results xml file. The test is for SAP 4.7. I need to save these bitmaps to files or at least export them to the html file using the export function in the test results viewer. Could you please help me with this problem? Thank you in advance! Best regards, Peter
How to test background color and dynamic images during run time can you put the check point for moving objects?
What are the trigger events in qtp?