bms Posted August 23, 2021 Share Posted August 23, 2021 This works OK: private string SQLQuery = "SELECT Data_Manager.Time_Stamp, Inverter.RemoteReady FROM Data_Manager JOIN Inverter ON Inverter.Time_Stamp LIMIT 1000" private FieldHandle = DB.Query(MySQLHandle, SQLQuery) ? DB.Field(FieldHandle, 1) But I get an error "O1004 Unable to run query" for this: private string SQLQuery = "SELECT Data_Manager.Time_Stamp, Inverter.RemoteReady FROM Data_Manager JOIN Inverter ON Inverter.Time_Stamp LIMIT 1000" private RO = DB.QueryToClass(MySQLHandle, SQLQuery) ? RO.FieldNames Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 23, 2021 Share Posted August 23, 2021 That error comes from the database itself. First you should try typing in the query directly into your database tool outside DAQFactory. That will often give you a more detailed error message. If it is successful, then the issue has to do with how DAQFactory does QueryToClass(). This function is designed for high efficiency acquisition of data from the database. As such, it first queries for the number of records so it can preallocate the required memory. It does this by replacing everything in the select with count(*), so: select field1, field2 from myTable would be replaced with select count(*) from myTable This works fine in most cases, but some more advanced queries, possibly like yours, it does not work with. In these cases you are forced to use the older and slower db.Query() function and read records one at a time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.