SQLTABLES( ) Function Example

The following example assumes an ODBC data source called MyFoxSQLNT is available, and the user ID for the data source is "sa." SQLCONNECT( ) is issued, and its return value is stored to a variable named gnConnHandle.

If you cannot connect to the data source, SQLCONNECT( ) returns a negative number and a message is displayed.

If you successfully connect to the data source, SQLCONNECT( ) returns a positive number and a dialog is displayed. SQLTABLES( ) is used to create a cursor named mycursor that contains information about tables in the data source. LIST is used to display information about the tables.

STORE SQLCONNECT('MyFoxSQLNT', 'sa') TO gnConnHandle
IF gnConnHandle < 0
   = MESSAGEBOX('Cannot make connection', 16, 'SQL Connect Error')
ELSE
   = MESSAGEBOX('Connection made', 48, 'SQL Connect Message')
   STORE SQLTABLES(gnConnHandle, 'TABLE', 'mycursor') TO nTables
   IF nTables = 1
      SELECT mycursor
      LIST
   ENDIF
ENDIF