SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Dec 2003
    Posts
    205
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    QTP using db connection & query

    Hello everyone,
    I'm running the following script where checks for a current invoice number in the db. the check i created in the if then statement passes and works fine. But based on the invoice number I would like to be able to pull additional data and write it to the local sheet but nothing gets written.
    Maybe someone can help me finding my mistake..
    here's the code;

    Dim InvoiceNum
    InvoiceNum = DataTable.Value("db2",dtGlobalSheet)
    sConnStr = "Provider=MSDASQL;DSN=yellowpages;UID=shay;PWD=nor mer;APP=QuickTest Professional;WSID=QA-TEST;DATABASE=yellow_pages_stg"
    set OBJdbConn = CreateObject("ADODB.Connection")
    msgbox InvoiceNum
    ' Create and open the connection object

    OBJdbConn.Open sConnStr

    ' Check for the new Invoice Number in the database if it exists then write companyid, companyname, username and password to sheet


    SQLquery = "SELECT P.InvoiceNumber, C.CompanyID, C.CompanyName, U.UserName, U.UserPassword " &_
    " FROM Company C, Payment P, Users U" &_
    " WHERE C.CompanyID = P.CompanyID AND U.CompanyID = C.CompanyID AND P.InvoiceNumber='" & InvoiceNum &"'"

    set RsReservationList = OBJdbConn.Execute(SQLQuery)
    DataTable.Value("db2",dtGlobalSheet)=InvoiceNum

    ' The ReportEvent function writes out a message to the test results sheet.
    If not RsReservationList.eof Then
    if (RsReservationList("InvoiceNumber") = InvoiceNum) then
    Reporter.ReportEvent 0, "Database Checkpoint", "Database checkpoint passed." & chr(13) & "Found record for user: " & InvoiceNum
    DataTable.Value("CompanyID",dtLocalSheet) = CompanyID
    DataTable.Value("CompanyName",dtLocalSheet) = CompanyName
    DataTable.Value("UserName",dtLocalSheet) = UserName
    DataTable.Value("UserPassword",dtLocalSheet) = UserPassword
    msgbox CompanyID
    msgbox CompanyName
    msgbox "test"
    else
    Reporter.ReportEvent 1, "Database Checkpoint", "Database checkpoint failed" & chr(13) & "Did not find record for user: " & InvoiceNum
    end if
    End If

    Thanks in advance for your help

  2. #2
    Junior Member
    Join Date
    Dec 2004
    Location
    chennai
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP using db connection & query

    Hi,

    Try to replace this

    DataTable.Value("CompanyID",dtLocalSheet) = CompanyID
    DataTable.Value("CompanyName",dtLocalSheet) = CompanyName
    DataTable.Value("UserName",dtLocalSheet) = UserName
    DataTable.Value("UserPassword",dtLocalSheet) = UserPassword

    with this

    DataTable.Value("CompanyID",dtLocalSheet) = RsReservationList.Fields("CompanyID")
    DataTable.Value("CompanyName",dtLocalSheet) = RsReservationList.Fields("CompanyName")
    DataTable.Value("UserName",dtLocalSheet) = RsReservationList.Fields("UserName")
    DataTable.Value("UserPassword",dtLocalSheet) = RsReservationList.Fields("UserPassword")

    Hopefully it should work
    Thanks,
    --KK--

  3. #3
    Member
    Join Date
    Dec 2003
    Posts
    205
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP using db connection & query

    thank you, --KK--
    it works great.

 

 

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 11.54%
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:48 AM.

Copyright BetaSoft Inc.