Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

Read Data from an Access Table with ODBC

  • Last UpdatedSep 16, 2025
  • 1 minute read

You can use a SELECT query to read data from an Access table or to call an Access query.

A query is preferred over a table if there are many more columns in the table than are needed at the time, if the data needs to be sorted, or if you need to relate or join several tables. The Cicode necessary is as follows:

Function SQLTest

INT hSQL, iResult;

hSQL = SQLConnect("DSN=ODBCTest;UID=YourUID_C;PWD=YourPWD");

IF hSQL <> -1 Then

iResult = SQLExec(hSQL, "SELECT * FROM qryRecipes

WHERE Recipe Between '3000' And '6000'");

IF iResult = 0 Then

WHILE SQLNext(hSQL) = 0 DO

TraceMsg(">" + SQLGetField(hSQL, "Recipe")

+ "<>" +SQLGetField(hSQL, "Flour")

+ "<>" +SQLGetField(hSQL, "Water")

+ "<>" +SQLGetField(hSQL, "Cocoa") + "<");

END

SQLDisconnect(hSQL);

ELSE

Message("SQL Error", SQLErrMsg, 48);

END

ELSE

Message("SQL Error", SQLErrMsg, 48);

END

END

See Also

Append Data with ODBC

Related Links
TitleResults for “How to create a CRG?”Also Available in