Applies To:
  • CitectSCADA 4.xx, 5.xx

If you have been using the Citect SQL functions via ODBC to SQL Server 6.5 or SQL Server 7, you may have noticed some problems using the SQLConnect() function.

In frustration, you have probably already resorted to defining your database as the default database in your DSN.  However, you can define the database at runtime. 

Help would lead you to try the following: (for example)

    hSQL = SQLConnect("DSN=MyDSN;SRVR=SQLSRVR;DB=MyDatabase;UID=sa;PWD=;");

However, this will not work unless the database name is specified as the default database when you configured your DSN "MyDSN". In fact you could leave out the "DB=MyDatabase" bit altogether and it will still work. (In fact it will only ever work with the default database)

However, you are supposed to be able to specify the target database with no default database specified, when calling the SQLConnect() function.  You can, but Help is wrong on how to do this.

The following WILL work where no default has been specified:


    //Note the DATABASE= rather than DB=

If you have been doing ODBC to MSAccess ".mdb"s then all of this is irrelevant anyway because you must specify the file name of the mdb in your DSN (and of course there is only ever 1 database in the mdb file) 

Connection String