To append data to an Access table using ODBC, you can use an SQL INSERT statement.
Function SQLInsert
INT hSQL, iResult;
hSQL = SQLConnect("DSN=ODBCTest;UID=YourUID;PWD=YourPWD");
IF hSQL <> -1 Then
iResult = SQLExec(hSQL, "INSERT INTO tblRecipes (Recipe, Flour, Water, Cocoa) VALUES ('X1234', 2, 3, 4)" );
SQLDisconnect(hSQL);
END
END
To avoid having to deal with SQL statements, you can use the standard Cicode device functions to append records to an Access table. First configure an SQL device. If the table has many fields that do not need to be written to, define only those fields that are necessary in the device definition (this keeps the device definition simple and reduces the number of DevWrite instructions). DevOpen, DevWrite and DevClose can then be used to add records to the table.
CitectSCADA accepts successive DevWrites until they equal the number of fields in the device definition at which time it constructs an SQL INSERT statement. The DevWrites needs to contain data for fields in the same order as the device definition. Do a DevOpen followed immediately by successive DevWrites for as many records as are necessary then a DevClose to avoid data being out of context.
See Also