Results 1 to 3 of 3

Thread: Connect Database

  1. #1
    Junior Member
    Join Date
    May 2007
    Answers
    4

    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


  2. #2
    Contributing Member
    Join Date
    Aug 2007
    Answers
    59

    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


  3. #3
    Contributing Member
    Join Date
    Feb 2006
    Answers
    85

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact