Applies To:
  • CitectSCADA 5.xx, 6.xx, 7.xx
  • CitectHMI 5.xx, 6.xx, 7.xx


How can I create or use a dBase (DBF) file with more than 128 fields (columns)? 


When CitectSCADA uses DBF files, it uses dBase III format which allows 128 fields. However, dBase IV format supports 250 fields. For Citect to use these files, it needs to connect using SQL/ODBC drivers. To connect using a System Device (Citect Project Editor | System menu | Devices), use these settings:

Device:   DbfDev
Header:   Dbq=c:\Data;Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;
FileName: Table1.dbf
Type:	 SQL_DEV
  • Make sure to set the output path in the Header field, and the output file in the Filename field.
  • An SQL Device can be used for alarm logging, reports (see Q2908, and the Device functions like DevOpen()
  • If you specify the Format for a dBASE_DEV device, Citect will automatically create the file if it does not exist. It will not automatically create the file for a SQL_DEV device. It is necessary to create the file in another application or use Cicode like the following.
	 INT hSQL = SQLConnect("DBQ=C:\Data;Driver={Microsoft dBase Driver (*.dbf)};DriverId=277");
	 SQLExec(hSQL, "CREATE TABLE Report1 ([Time] TEXT(10), Tag TEXT(79), [Value] TEXT(32));");

Use square brackets around field names that are reserved SQL keywords like 'Value'.

You can also connect to the file using SQLExec(). Just use the text from the header field above as the connection string, and use the DBF file name as the table name in queries:

hSQL = SQLConnect("DBQ=C:\Data;Driver={Microsoft dBase Driver (*.dbf)};DriverId=277");
SQLExec(hSQL, "SELECT * FROM Table1");