Results 1 to 9 of 9

Thread: DBTable object in QTP

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Answers
    23

    DBTable object in QTP

    Hi All ,
    Has anybody worked on DBTable object in QTP? I'm facing one problem.... I'm preparing a connection string as "strConnSQL = "Provider=SQLOLEDB.1;Password=" & strPassword & ";User ID=" & strUserName & ";Initial Catalog=" & strDatabase & ";Data Source=" & strServerName " for SQL Server. I have added one database checkpoint in my script. Now according to the script the strPassword , strUserName & strDatabase parameters are changing. If I set property of DBTable's "ConnectionString" property , it is not taking it at runtime. QTP is taking this property which I set during design time ie from OR. How can I change this property at runtime?
    My code sample is as follows:
    ____________________________________________________________________________________
    strGroup = "DBO"
    strUserName="demo"
    strPassword="demo"
    strServerName="YSI-IN-VSQL"
    strDatabase="c6008"
    strPlatform = "SQL"
    strConnSQL = "Provider=SQLOLEDB.1;Password=" & strPassword & ";User ID=" & strUserName & ";Initial Catalog=" & strDatabase & ";Data Source=" & strServerName
    'Set SQL
    MsgBox DbTable("DbTable").GetTOProperty("Source") & vbCrLf & DbTable("DbTable").GetTOProperty("DBUniqueID") & vbCrLf & DbTable("DbTable").GetTOProperty("ConnectionString") , , "Before Setting"
    DbTable("DbTable").SetTOProperty "ConnectionString" , strConnSQL
    MsgBox DbTable("DbTable").GetTOProperty("Source") & vbCrLf & DbTable("DbTable").GetTOProperty("DBUniqueID") & vbCrLf & DbTable("DbTable").GetTOProperty("ConnectionString") , , "After Setting"
    DbTable("DbTable").Check CheckPoint("DbTable")
    ____________________________________________________________________________________
    Can anybody help me out? ???


  2. #2

    Re: DBTable object in QTP

    Try this:

    strGroup = "DBO"
    strUserName="demo"
    strPassword="demo"
    strServerName="YSI-IN-VSQL"
    strDatabase="c6008"
    strPlatform = "SQL"
    strConnSQL = "Provider=SQLOLEDB.1;Password=" & strPassword & ";User ID=" & strUserName & ";Initial Catalog=" & strDatabase & ";Data Source=" & strServerName
    'Set SQL
    MsgBox DbTable("DbTable").GetTOProperty("Source") & vbCrLf & DbTable("DbTable").GetTOProperty("DBUniqueID") & vbCrLf & strConB=DbTable("DbTable").GetTOProperty("ConnectionString") , , "Before Setting"
    DbTable("DbTable").SetTOProperty "ConnectionString" , strConnSQL
    MsgBox DbTable("DbTable").GetTOProperty("Source") & vbCrLf & DbTable("DbTable").GetTOProperty("DBUniqueID") & vbCrLf & strConA=DbTable("DbTable").GetTOProperty("ConnectionString") , , "After Setting"
    DbTable("DbTable").Check CheckPoint("DbTable")

    Now, if you want to compare the values for BeforeSetting and AfterSetting, it can be done by comparing strConB and strConA.

    Also, if you want to change property at run-time, since there is no SetTOProperty, you will have to use:

    objectType().object.objectProperty="new_value"

    Refer to this thread: http://www.geekinterview.com/talk/38...an-object.html


  3. #3
    Junior Member
    Join Date
    Nov 2007
    Answers
    23

    Unhappy Re: DBTable object in QTP

    Hi Anshoo ,
    I tried your given code but it's not working...The statement where value is assigned to variable in MsgBox statement , returns "False" & values of the variables as Blank...Again I'm unable to get object for "DBTable"....hence cannot use the statement ObjectType().Object.ObjectProperty = "New_Value"..... SO problem is still there....


  4. #4

    Re: DBTable object in QTP

    Let me know if this works (or doesn't):

    strConnSQL="Provider=SQLOLEDB.1;Password="&strPassword&";User ID="&strUserName&";Initial Catalog="&strDatabase&";Data Source="&strServerName
    strSrcB=DbTable("DbTable").GetTOProperty("Source")&vbCrLf
    strIDB=DbTable("DbTable").GetTOProperty("DBUniqueID")&vbCrLf
    Print strSrcIDB
    Print strIDB
    strConB=DbTable("DbTable").GetTOProperty("ConnectionString") , , "Before Setting"
    Print strConB
    DbTable("DbTable").SetTOProperty "ConnectionString",strConnSQL
    strSrcA=DbTable("DbTable").GetTOProperty("Source")&vbCrLf
    strIDA=DbTable("DbTable").GetTOProperty("DBUniqueID")&vbCrLf
    Print strSrcIDA
    strConA=DbTable("DbTable").GetTOProperty("ConnectionString") , , "After Setting"
    Print strConA
    DbTable("DbTable").Check CheckPoint("Give_some_other_name_to_this_chkPT")

    Last edited by Anshoo_Arora; 01-22-2008 at 10:37 PM.

  5. #5
    Junior Member
    Join Date
    Nov 2007
    Answers
    23

    Thumbs up Re: DBTable object in QTP

    Hi Anshoo ,
    Thanks for giving your valuable time for this....your code didn't work, but I got a solution for this. Thanks for all your help.


  6. #6
    Junior Member
    Join Date
    Sep 2007
    Answers
    13

    Re: DBTable object in QTP

    Hi Manabh,

    Please can I know what was the fix or solution you found for that. If you write in descriptive method, it will much more helpfull..


  7. #7
    Junior Member
    Join Date
    Nov 2007
    Answers
    23

    Thumbs up Re: DBTable object in QTP

    Hi,
    This is not in a descriptive method. Simply through OR , for Source Property, I set an environmental variable & same for connectionstring property. Assigned values to these environmental variables & I was able to change the properties runtime.


  8. #8
    Junior Member
    Join Date
    Sep 2007
    Answers
    13

    Re: DBTable object in QTP

    Manabh,

    Thanks for writing the information !


  9. #9

    Re: DBTable object in QTP

    I didn't really write my own code but was trying to understand what your code was doing. I just tried to modularie it where I can. The soluation to change runtime property was given in my earlier post and I am not quite sure why it didn't work for you.


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