Using Legacy Functions
Before you can use SQL commands, you need to connect to the SQL database. In previous versions of Citect SCADA you would use the
SQLConnect(sConnect);
where sConnect
is the connection string, for example:
INT hSQL;
hSQL = SQLConnect("DSN=DBASE_FILES;DB=C:\ODBC\EMP;LCK=NONE;CS=ANSI");
! Connect to a dBASE Compatible Database File.
INT hSQL;
hSQL = SQLConnect("DSN=EXCEL_FILE;DB=C:\ODBC\EMP;FS=10");
! Connect to an Excel File.
INT hSQL;
hSQL = SQLConnect("DSN=ORACLE_TABLES;SRVR=X:ACCTS;UID=SCOTT;PWD=TIGER");
! Connect to an Oracle Database.
Refer to the documentation that accompanied your SQL server for details about connecting to an SQL database.
To close a legacy database connection, use the
Using ADO.NET Functions
The new interface requires two calls in order to open a connection to a database. The first call uses
SQLOpen can be used to reopen previously closed connections.
Note: SQL connections to databases can be closed sometimes by either databases or ADO.NET when certain conditions are fulfilled (for example through idle time expiration, active pooling mechanism logic).
To close an ADO.NET database connection, use the
New functions can be used with the pre-existing ones. However, as a good programming practice, it is advised not to mix the old and the new interface. A hardware alarm will be generated if a SQLDisconnect is detected when there are connections opened with SQLCreate/SQLOpen, or if SQLClose/SQLDispose are detected and there are connections opened with SQLConnect.
See Also
Published June 2018