SQLSTRINGCONNECT( ) Function Example
The following example assumes an ODBC data source called MyFoxSQLNT is available, and the user ID for the data source is "sa," and the password is "FOXPRO." SQLSTRINGCONNECT( ) is issued, and its return value is stored to a variable named gnConnHandle
.
If you successfully connect to the data source, SQLSTRINGCONNECT( ) returns a positive number, a dialog is displayed and SQLDISCONNECT( ) is used to disconnect from the data source.
If you cannot connect to the data source, SQLSTRINGCONNECT( ) returns a negative number and a message is displayed.
STORE SQLSTRINGCONNECT('dsn=MyFoxSQLNT;uid=sa;pwd=FOXPRO');
TO gnConnHandle
IF gnConnHandle < 0
= MESSAGEBOX('Cannot make connection', 16, 'SQL Connect Error')
ELSE
= MESSAGEBOX('Connection made', 48, 'SQL Connect Message')
= SQLDISCONNECT(gnConnHandle)
ENDIF