Database Exchange > Using a dBase DBF as a Data Source > Using a DSN as a Data Source

Using a DSN as a Data Source

To use a DSN as a data source:

  1. Insert Database Exchange on a graphics page using the Citect Graphics Builder.
  2. Double-click the Database Exchange object to display the Properties dialog box.
  3. Click the Connection tab and then click Build.
  4. On the Data Link Properties dialog box, select Microsoft OLE DB Provider for ODBC Drivers and then click Next.
  5. Select Demo on the DSN list.
  6. Optionally, select the data directory from the list as Initial Catalog to use. (This setting is included in the DSN definition already.)
  7. Test the connection and then click OK.
  8. If the schema is retrieved successfully, you should be able to see all the DBF files located in your Example project directory on the list on the Database Exchange properties form. Select a DBF file you want to display from the list and then click Apply.

Sometimes MDAC might not be configured correctly for ODBC drivers, so multiple-step OLE DB operation would generate errors during open schema process. It means that no DBF files are listed on the dropdown list. In this case, you should use either Unknown or SQL Statement as the record source type. For example, if you want to display data from Recipes.dbf file, you could use the following methods.

  1. Using type Unknown – type Recipes in the Unknown Command Text field.
  2. Using type SQL Statement – type Select * From Recipes in the SQL Statement field.

Note: If SQL Statement is used, you can use aWhere clause to filter the displayed data. For instance, you could enter Select * From Recipes Where Name=’White’.

As a result, there would be a record displayed on the control. You can use any DBF file in the configured folder as a record source.