Micro Focus QTP (UFT) Forums
Using an output value as input to a SQL statement - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Using an output value as input to a SQL statement (/Thread-Using-an-output-value-as-input-to-a-SQL-statement)



Using an output value as input to a SQL statement - egun - 07-30-2009

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


RE: Using an output value as input to a SQL statement - Jackomcnabb - 07-30-2009

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


RE: Using an output value as input to a SQL statement - egun - 08-04-2009

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.