Applies To:
  • CitectSCADA 6.00
  • CitectHMI 6.00

On a remote client (Full, IDC or Web), I want the user to be access a database, but I am not able to configure the DSN on the client machine. Is there a way to connect to a database without defining a DSN? 

Use a FileDSN,

This can be used by Citect without defining a normal DSN as follows

- Create a File DSN (this can be done using the ODBC Administrator --> File DSN --> Add...)

- put the .DSN file that is created in your project dir (or any standard dir on all the clients)

- In CiCode use --> SQLConnect("FILEDSN=" + sPath); where sPath contains the full path to the .DSN file (e.g. "C:\OurSQLConn.dsn")

You can also use something like --> PathToStr("[RUN]:\OurSQLConn.dsn") if you want more flexibility in paths (remember you can add your own path substitutions with the [Path] Alias=C:\Anydir\Anydir)

Solution courtesy of Jeroen Brattinga, Bouwhuis Regeltechniek, Zwolle Netherlands

Use a Registry File to dynamically create a DSN

You can generate a file similar to the following settings by exporting from HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI, then clipping out what you don't want on the target machines. I have provided an example below.

You can apply the changes from Cicode - something like

exec("regedit.exe addDSN.reg");

---clip here---
Windows Registry Editor Version 5.00
---clip here---

Solution courtesy of Chris Ghormley, Setpoint Control, Portland USA