-
Junior Member
Connect Database
How to connect to a database in QTP.
I want to get connected to the flight_application database and extract some records from there and then save it to a excel sheet.
Kindly provide me the code its urgent please
-
Contributing Member
Re: Connect Database
you can use Datatable Export (storing location) to store runtime data table into the required location
you can also use Datatable export sheet storing location sheet name
to store particular runtime datatable sheet in required location
-
Contributing Member
Re: Connect Database
you can use the following piece to do a connection for you please update it according to your changes.
hope this helps ,
Kunals.
'Create the connection string:
strConn="DRIVER={SQL Server};SERVER="&ServerName&";database=" & DBName & ";User ID=" & UserID & ";Password=" & PWD & " ;"
'Establish the connection:
Set oConn = CreateObject("ADODB.Connection")
'Server-side cursor
oConn.CursorLocation = 2
oConn.Open strConn
'Create a recordset to hold the results
Set rs = CreateObject("ADODB.Recordset")
'Options for CursorType are: 0=Forward Only, 1=KeySet, 2=Dynamic, 3=Static (read-only)
rs.CursorType = 3
Set rs.ActiveConnection = oConn
'Execute the query and put the results into the recordset
rs.Open SQLQuery
NumberOfColumn=rs.fields.count
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules