JavaScript Editor js editor     Web development 



Main Page

Terminates a connection to a data source.

SQLDISCONNECT(nStatementHandle)

Parameters

nStatementHandle


Specifies the statement handle to the data source returned by SQLCONNECT(В ). Specify 0 for nStatementHandle to terminate all active connections.

Return Value

Numeric. SQLDISCONNECT( ) returns 1 if the connection is successfully terminated, – 1 if there is a connection level error, and – 2 if there is an environment level error.

Remarks

SQLDISCONNECT(В ) terminates a connection to a data source. You must supply the statement handle that SQLCONNECT(В ) returned when you established the connection.

Note:
If you execute SQLDISCONNECT(В ) within an asynchronous function sequence or during a transaction, SQLDISCONNECT(В ) generates an error.

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 successfully connect to the data source, SQLCONNECT(В ) returns a positive number, a dialog box is displayed and SQLDISCONNECT(В ) is used to disconnect from the data source.

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

В Copy Code
STORE SQLCONNECT('MyFoxSQLNT', '<userid>', '<password>') TO gnHandle
IF gnHandle <= 0
   = MESSAGEBOX('Cannot make connection', 16, 'SQL Connect Error')
ELSE
   = MESSAGEBOX('Connection made', 48, 'SQL Connect Message)
   = SQLDISCONNECT(gnHandle)
ENDIF

See Also



JavaScript Editor js editor     Web development 
R7