70. How To Execute A Parameterized SQL Query In QTP Script?
Date Posted: 06/27/2012
Ans: Actually my requirement is, query should be parameterized. i.e., query should be in the script and also it should change dynamically. I.e. i have to pass different values in the query condition field based on different criteria’s. (Where condition)
In this procedure (Which you have mention)?can we change the SQL query? If we can plz let me know once.
For this i? Am following the below process (Which ? Came to know? recently). Here i am giving the procedure. Plz check it once.
1.Connect to the database:????????????
strCon="Driver={Microsoft ODBC for Oracle}; " &_
"CONNECTSTRING = (DESCRIPTION = " &_
"(ADDRESS = (PROTOCOL = TCP)" &_
"(HOST=XXXX) (PORT=XXXX))" &_
"(CONNECT_DATA = (SERVICE_NAME=xxxxxxx))); uid=xxxxx;pwd=xxx;"
2. Open the database connection
Set oCon=Create Object ("ADODB.Connection")
3.? Create the record set object
Set oRs=Create Object("ADODB.Recordset")
4.?Define the Parameterized SQL query
strQuery="Parameterized query"
5. Execute the query
Set oRs=oCon. Execute (strQuery)
After that we can manipulate the record set values accordingly.
|