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: [url]http://www.geekinterview.com/talk/3827-change-runtime-property-of-an-object.html[/url]
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....
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")
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.:)
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..
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.:)
Re: DBTable object in QTP
Manabh,
Thanks for writing the information !
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.