Database Step Types
- Updated2025-03-28
- 2 minute(s) read
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.
- Review the following steps in the MainSequence:
- 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.
- The Open Database step opens the database for use in TestStand, returns a handle, and stores the handle in the DatabaseHandle local variable.
- The Drop Table step, which is an Open SQL Statement step, drops the TEST_TABLE database table, if it exists.
- The Create Table step, which is an Open SQL Statement step, creates the TEST_TABLE table.
- The Open SQL Statement step selects all columns in the TEST_TABLE table.
- 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.
- 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.
- The Cleanup step group contains Close SQL Statement and Close Database steps.
- Select Execute»Single Pass to run the sequence.
- When execution completes, select Tools»Database Viewer to launch the TestStand Database Viewer application.
- Select File»Open, browse to <TestStand Public>\Examples\Database\Access.mdb, and click OK.
- Right-click the TEST_TABLE table and select View Data from the context menu to display the data contained in the TEST_TABLE table.