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