Cicode Programming Reference > Cicode Function Categories > SQL Functions Introduction > SQLDisconnect


Closes a database connection. You should close all connections to databases before you shut down CitectSCADA, to release system resources.

For each active transaction (that is, for each SQLBeginTran() call), you should complete the transaction before you disconnect from the database call SQLCommit() to save your changes, or SQLRollBack() function to discard changes. If you call SQLDisconnect() while a transaction is still active, CitectSCADA automatically "rolls back" the transaction any changes you made to the database in that transaction are discarded.

CitectSCADAalso automatically ends any queries that are active when the database is disconnected. If you have called SQLExec() during a database connection, you need to call SQLEnd() before you disconnect from the database or the disconnection attempt might not succeed.




The handle to the SQL connection, returned from the SQLConnect() function. The SQL connection handle identifies the table where details of the associated SQL connection are stored.

Return Value

0 (zero) if successful, otherwise an error number is returned. (For details of the 307 error code, call the SQLErrMsg function).

You should not call SQLErrMsg() if SQLDisconnect() returns zero (that is, if the disconnection is successful). SQLErrMsg() would provide information about a connection that does not exist; the information could be meaningless.

Related Functions

SQLBeginTran, SQLCommit, SQLConnect, SQLEnd, SQLErrMsg, SQLExec, SQLFieldInfo, SQLGetField, SQLInfo, SQLNext, SQLNoFields, SQLNumChange, SQLRollBack, SQLTraceOff, SQLTraceOn


See SQLConnect

See Also

SQL Functions