JavaScript Editor js editor     Web development 



Main Page

Stores the names of tables in a data source to a Visual FoxPro cursor.

SQLTABLES(nStatementHandle [, cTableTypes] [, cCursorName])

Parameters

nStatementHandle


Specifies the statement handle to the data source returned by SQLCONNECT(В ).
cTableTypes


Specifies one or more table types. Valid table types are 'TABLE,' 'VIEW,' 'SYSTEM TABLE,' or any valid data source-specific table type identifier. If you include a list of table types, separate the table types with commas. All table names in the data source are selected if you omit cTableTypes or if cTableTypes is the empty string. The table type you specify must be delimited with single quotation marks. The following example demonstrates how to specify the 'VIEW' and 'SYSTEM TABLE' table types as a string literal.
В Copy Code
? SQLTABLES(handle, "'VIEW', 'SYSTEM TABLE'", "mydbresult")
cCursorName


Specifies the name of the Visual FoxPro cursor to which the result set is sent. If you don't include a cursor name, Visual FoxPro uses the default name SQLRESULT. The structure of the results depends on the internal SQLTABLES(В ) function for the ODBC Handle.

Return Value

Numeric. SQLTABLES( ) returns 1 if the cursor is successfully created, 0 if SQLTABLES( ) is still executing, – 1 if a connection level error occurs, and – 2 if an environment level error occurs.

Remarks

SQLTABLES(В ) is one of the four functions that you can execute either synchronously or asynchronously. The setting of the SQLSETPROP(В ) asynchronous option determines if these functions execute synchronously or asynchronously. In asynchronous mode, you must call SQLTABLES(В ) repeatedly until it returns a value other than False (.F.), meaning the function is still executing.

Example

The following example assumes an ODBC data source called MyFoxSQLNT is available. SQLCONNECT(В ) is issued, and its return value is stored to a variable named gnHandle.

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.

В Copy Code
STORE SQLCONNECT('MyFoxSQLNT', '<userid>', '<password>') 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

See Also



JavaScript Editor js editor     Web development