Micro Focus QTP (UFT) Forums

Full Version: Using an output value as input to a SQL statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm hoping someone can help me. I'm wondering if it is possible to use an output value that I have stored in my test run and use it as input in a SQL statement (Database checkpoint). The output value is a parameter so it can change from run to run, hence my reason to be able to use the run's output value in the SQL query. Is there a way to do this? I have tested my connection but need to drill down and figure out how to word the query.

Any input would be appreciated! Thank you.
Big Grin
You can pass a variable to a string then pass that string to the DB Query:
Code:
ZipCode="12345"
sqlstring= "SELECT count(*)  FROM LOCCITY WHERE  LOCCITY.LOCZIPCODESTART LIKE '"&ZipCode&"%' "

Set Rec = CreateObject("ADODB.Recordset")
SQL= ""&sqlstring&" "
Rec.open SQL ,conn

as you can see I'm just getting the count back
When I attempt this, I get an error message:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Line (49): "Rec.open SQL ,conn".

I copy/pasted what you wrote -
Keep in mind that I am very new to QTP. Thanks! Any response is appreciated.