Purpose

This example demonstrates how to use the Database step types to delete and create tables in a database, as well as how to modify the records in the database.

Example File Location

<TestStand Public>\Examples\Built-In Step Types\Database Step Types\Database Step Types.seq

Highlighted Features

Database step types

Major API

None

Prerequisites

(32-bit TestStand) You must have the Microsoft Jet 4.0 Object Linking and Embedding Database (OLE DB) Provider installed. (64-bit TestStand) You must have the Microsoft Access Database Engine 2010 Redistributable installed. Visit ni.com/info and enter the Info Code 64TSaccdb to access the NI support article, Using Microsoft Access Databases with 64-bit TestStand, for more information about installing this provider.

How to Use This Example

Complete the following steps to use this example.

  1. Review the following steps in the MainSequence:
    1. The Find Access MDB File step, which is a Statement step, attempts to locate the Microsoft Access database file (.mdb) and store its path in the MDBFilePath local variable.
    2. The Open Database step opens the database for use in TestStand, returns a handle, and stores the handle in the DatabaseHandle local variable.
    3. The Drop Table step, which is an Open SQL Statement step, drops the TEST_TABLE database table, if it exists.
    4. The Create Table step, which is an Open SQL Statement step, creates the TEST_TABLE table.
    5. The Open SQL Statement step selects all columns in the TEST_TABLE table.
    6. The SQL Action - Set Values step, which is a Data Operation step, adds data to the TEST_TABLE table and loops 10 times because the Goto step that follows the SQL Action - Set Values step targets the Start Loop step, which is a Label step, and specifies a post action and precondition that starts and stops the loop.
    7. The Start Loop 2 step starts a second loop that uses Data Operation steps to obtain the values and strings written to the TEST_TABLE table.
    8. The Cleanup step group contains Close SQL Statement and Close Database steps.
  2. Select Execute»Single Pass to run the sequence.
  3. When execution completes, select Tools»Database Viewer to launch the TestStand Database Viewer application.
  4. Select File»Open, browse to <TestStand Public>\Examples\Database\Access.mdb, and click OK.
  5. Right-click the TEST_TABLE table and select View Data from the context menu to display the data contained in the TEST_TABLE table.