Results 1 to 3 of 3
  1. #1

    Issue in Storing Multiple Records in Variable


    I am new to QTP Automation Testing, but with few months of training I have got a good comfort feel in creating QTP Scripts
    While In this process, I am facing an issue to store values of multiple records from a recordset using an SQL Query.

    The Code which I have created to connect to DB and get the values is as follows:
    <font class="small">Code:</font><hr /><pre>
    Set conn = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")
    conn.Open "My Connection String"
    rs.open "select suggested_savings, savings_code, reason, clinical_logic from detects.claim_item_review,conn
    Do While not rs.EOF
    suggested_savings = Trim(rs(0))
    savings_code = Trim(rs(1))
    reason_code = Trim(rs(2))
    clinical_logic = Trim(rs(3))
    </pre><hr />

    By this way, I am able to capture all the values from the recordset, but can use only the last record of the recordset, which would be used in the later part of my QTP script. What modification do I have to do, to capture values from all the records in the recordset.
    I know that I have to got use array out here, but I dont know the correct way of doing it.
    So, Any help in this issue would be appreciated.

    Thanking You

    Satish Kumar

  2. #2

    Re: Issue in Storing Multiple Records in Variable

    For using array try the below code.
    i = 0
    Do While not rs.EOF
    suggested_savings(i) = Trim(rs(0))
    savings_code(i) = Trim(rs(1))
    reason_code(i) = Trim(rs(2))
    clinical_logic(i) = Trim(rs(3))
    i = i + 1

    If you need to refer the values, may they can stored in the datatable also.
    -- Here to Learn and share ---

  3. #3

    Re: Issue in Storing Multiple Records in Variable

    Thank You Jonty for a very quick reply. Your script has really helped me out



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:18 PM.

Copyright BetaSoft Inc.