Results 1 to 5 of 5

Thread: How to Import the data from MS-Access in QTP?

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Answers
    27

    How to Import the data from MS-Access in QTP?

    Hi,

    Any one tell me How to Import the data from MS-Access in QTP?


  2. #2
    Expert Member
    Join Date
    Oct 2007
    Answers
    375

    Smile Re: How to Import the data from MS-Access in QTP?

    Hi Ramya,

    You can use the same createObject method to export data from MS Access as well. Here is the code guideline for the following -

    dim oConn
    dim sRec

    set oConn = createObject("ADODB.Connection")
    oConn.open "Provider = Microsoft.Jet.OLEDB.4.0;DataSource = <
    NOTE : Incase authentication is required as in case of SQL Server, we would have to pass UserID and Pwd as well.

    set sRec = createObject("ADODB.Recordset")
    sRec.open "Select * from where .... conditions", oConn, adLockOptimistic, adOpenDynamic

    for i = 0 to rs.EOF
    ar[i] = sRec.fields(i)
    next

    NOTE : Incase rs.EOF does not work, try the following code -

    dim item
    For each item in sRec.fields

    Next
    sRec.MoveNext

    Cheers......


  3. #3
    Junior Member
    Join Date
    Feb 2008
    Answers
    2

    Re: How to Import the data from MS-Access in QTP?

    Thanks, this was a really useful post


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

    Re: How to Import the data from MS-Access in QTP?

    Hi ramya, here you can use this code for getting data from database by using msaccess..

    ''''''''''''''To Retrieve the Data From Database''''''''''''''''''''''''''''''''''''''''''''''''''''

    '''''To retrieve the data from two tables''''''''''''''''''''''''''''


    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 Orders.Customer_Name,Flights.Departure from Orders,Flights where Orders.Flight_Number=Flights.Flight_Number")

    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
    objConnection.Close

    _________________________
    Thanks & Regards

    Arun Singh Rajaputra


    Last edited by rajaputra; 03-20-2008 at 12:07 PM.

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

    Re: How to Import the data from MS-Access in QTP?

    Hi Ramya,

    Here you can use this code for getting data from database by using msaccess..


    ''''''''''''''To Retrieve the Data From Database''''''''''''''''''''''''''''''''''''''''''''''''''''

    '''''To retrieve the data from two tables''''''''''''''''''''''''''''


    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 Orders.Customer_Name,Flights.Departure from Orders,Flights where Orders.Flight_Number=Flights.Flight_Number")

    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
    objConnection.Close

    _____________________
    Thanks & Regards

    Arunsingh Rajaputra



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