Results 1 to 2 of 2

Thread: Database Conneciton and SQL Queries

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Answers
    5

    Database Conneciton and SQL Queries

    Hi everybody I am preparing for job in QA, I learned WR, QTP on my own . I want to write script for database testing, but i cannot install database on my laptop? I want to know the script for database connection , how and where to use sql queries in the script, Can anybody explain with example script?


  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    110

    Re: Database Conneciton and SQL Queries

    Hi Siteuse,

    This for retrieving the data from database(MS ACCESS)

    Dim Dsn_conn,rs

    Set objConnection=Createobject("ADODB.Connection")'Create connection object with DSN
    Dsn_conn= "DSN=QT_Flight32;DBQ=C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\
    flight32.mdb;Driver=C:\WINNT\system32\odbcjt32.dll;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
    objConnection.Open(Dsn_conn)'Open the connection
    Set rs=CreateObject("ADODB.RecordSet") 'Create recordset object

    'Set rs=objconnection.execute(" select Order_Number,Customer_Name from Orders where Order_Number>10")'Execute the query
    Set rs=objconnection.execute("select Orders.Customer_Name,Flights.Departure from Orders,Flights where Orders.Flight_Number=Flights.Flight_Number")'''Here you have to write SQL Query
    rs.MoveFirst
    row=1
    datatable.GetSheet(1).addparameter"Customer_Name",""
    datatable.GetSheet(1).addparameter"Departure",""
    While Not rs.EOF
    ONumber=rs.fields.item("Customer_Name")
    CName=rs.fields.item("Departure")
    datatable.SetCurrentRow(row)
    datatable.Value (1,1)=ONumber
    datatable.Value(2,1)=CName
    row=row+1
    rs.movenext
    Wend
    'Close the connection


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