Micro Focus QTP (UFT) Forums
how to write query - 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: how to write query (/Thread-how-to-write-query)



how to write query - stevol - 05-15-2008

hi,
i proved to do this code:

Code:
Dim rs, conn, customerid
set conn=createobject("adodb.connection")
set rs=createobject("adodb.recordset")
conn.ConnectionString = "Provider=OraOLEDB.Oracle; Data Source=<SOURCE>; User ID=<USER>; Password=<PWD>; PLSQLRSet=1;"
conn.open
customerid="select 'ciao' from dual"
rs.open customerid, conn
rs.close
set rs=nothing
conn.close
set conn=nothing
msgbox customerid

But in the msgbox i see "select 'ciao' from dual" and not "ciao"... how can to save the query result in a variable?

thx,
ste


RE: how to write query - stevol - 05-15-2008

ok, i have found the solution.. thx howewer :-)

Code:
Dim rs, conn, query, customerid
set conn=createobject("adodb.connection")
set rs=createobject("adodb.recordset")
conn.ConnectionString = "Provider=OraOLEDB.Oracle; Data Source=<SOURCE>; User ID=<USER>; Password=<PWD>; PLSQLRSet=1;"
conn.open
query="select 'ciao' as pippo from dual"

Set rs= conn1.Execute(query)
var   = rs.fields("pippo")

rs.close
set rs=nothing
conn.close
set conn=nothing

msgbox var