background image
<< Lesson 8 Testing Databases | Installing the ODBC driver >>

DBTester functions

<< Lesson 8 Testing Databases | Installing the ODBC driver >>
134
Getting Started: A Tutorial
8 T
ESTING
D
ATABASES
Overview of DBTester
DBTester functions
The set of DBTester functions is summarized here. More detailed
descriptions and examples are included in the online Help.
Using the functions in
a testcase
The sample file dbtester.t shows how to use the DBTester functions together
in a simple testcase that prints a customer list from the client/server version
of GMO. (You can find this file in <GMO installation directory>/Exercise.
Do not use the dbtester.t file in the <SilkTest installation directory>/
Exercise.)
testcase DBTester () appstate none
//Use the DBTester functions to access the GMO database
//Print GMO's customer list
STRING custnum, lname, fname
HDATABASE hdbc
HSQL hstmnt
// Connect to the GMO database, green2.mdb
hdbc = DB_Connect ("dsn=
gmovb
")
// Retrieve everything from the customer table sorted by
// last name
hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM cidb
ORDER
BY last_name")
// Process the retrieved data and print customer names
Function
Description
DB_Connect
Opens a database connection and returns a handle to
that system. SQL statements can be submitted to the
database.
DB_Disconnect
Closes the connection between SilkTest and the
database and releases all resources.
DB_ExecuteSql
Sends an SQL statement to the database for execution.
DB_FetchNext
Retrieves the next row from the database.
DB_
FetchPrevious
Retrieves the previous row from the database.
DB_FinishSql
Removes the result of the SQL statement and releases
the associated system resource (statement handle).