SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to run multiple DB queries in QTP

    Hi,

    I want to store the result of multiple queries in one recordset.
    Set objDB = CreateObject("ADODB.Connection")
    Set objRecordset = CreateObject("ADODB.Recordset")
    totalquery=4
    for j=0 to totalQuery-1
    strQuery=strQueryArray(i)
    objRecordset.Open strQuery, objDB
    ...
    ...
    Next

    One iteration goes sucessfully, for next iteration i got error " operation is not allowed object is open".

    is there any way to use the same recordset for all queries.

    Thanks,
    Anjali

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to run multiple DB queries in QTP

    hi,

    I got the solution.
    Since i was storing the records from the recordset in an array, so i can simply use "set objRecordset=nothing"
    before moving to next iteration and create recordset inside loop only.

    eg:
    Set objDB = CreateObject("ADODB.Connection")
    totalquery=4
    for j=0 to totalQuery-1

    Set objRecordset = CreateObject("ADODB.Recordset")

    strQuery=strQueryArray(i)
    objRecordset.Open strQuery, objDB
    ...
    ...
    set objRecordset = nothing
    Next

    Its working fine now

    Thanks,
    Anjali

  3. #3
    Member
    Join Date
    Mar 2012
    Location
    Chennai
    Posts
    128
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to run multiple DB queries in QTP

    Hi Anjali,

    Can u give connectionstring line.

    i used this below line, but getting operation is not allowed when object is open...

    Conn.ConnectionString = "Provider=SQLNCLI10; Data Source=172.31.60.190; database=eip;Uid=testingteam;Pwd=password;"


    Regards,
    Indra

  4. #4
    Member
    Join Date
    Mar 2012
    Location
    Chennai
    Posts
    128
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to run multiple DB queries in QTP

    Me too got the solution. Thanks.

  5. #5
    Apprentice
    Join Date
    May 2007
    Posts
    45
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to run multiple DB queries in QTP

    Set objRecordset = CreateObject("ADODB.Recordset")
    set objRecordset = nothing


    1) Would be good to have the above 2 statements outside the for loop. Why create the Recordset object multiple times?

    2) Would also be worth considering stored procedures to get your job done.
    -Venu Yalluri

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:38 PM.

Copyright BetaSoft Inc.