Using SQL queries programmatically
In the previous recipe, we discussed how to use a UFT DB checkpoint. Here, we will show you how to execute a SQL statement using VBScript code.
Getting ready
We will use the function library DB_Func.vbs
as in the previous recipe Establishing and closing a database connection.
How to do it...
In our custom class DB_Handler
, we will add a new private m_oRecordset
field to hold the results of our query and a new method executeSQLQuery(SQLQuery)
, which, of course, accepts a string with a valid SQL query as the argument:
Private m_oRecordset function executeSQLQuery(SQLQuery) Set m_oRecordset = m_oDBConnection.Execute(SQLQuery) End Function
Additionally, in our Action1
datasheet, we would call the executeSQLQuery(SQLQuery) ...
Get Advanced UFT 12 for Test Engineers Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.