urdey Posted August 11, 2020 Share Posted August 11, 2020 Dear Sir I am trying to open MySQL databases as connection to ODBC with MySQL is ok . Communicating Daqfactory with MySQL showing unable to open database and I want to read tables and want to display the content of the table on the page. Best Regards Udipta Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 13, 2020 Share Posted August 13, 2020 I would try an older version of the MySQL ODBC driver. I usually just use 3.51 as that works reliably. Quote Link to comment Share on other sites More sharing options...
urdey Posted August 14, 2020 Author Share Posted August 14, 2020 I changed the driver 3.5 dbase open but I want to read temperature unable to run query Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 14, 2020 Share Posted August 14, 2020 You need spaces around the *: select * from temperature; And I'm assuming temperature is the name of your table? Quote Link to comment Share on other sites More sharing options...
urdey Posted August 14, 2020 Author Share Posted August 14, 2020 yes, temperature name of the table. I would be grateful if you tell me the format to read the table through a query command and displaying the value or a channel or update the channel. global dbase global qr global count global thetime global batch global start global strTime global dbase = db.Open("arduino") db.queryToClass(dbase, "select * from arduino;") db.execute(dbase, "update table1 set NAME = 'xyz' where ID=60") //global qr =db.QueryToClass(dbase,"select*from temperature") error message O1004 Unable to run query: db Line 19 - Uncaught error in sequence db Regards Udipta Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 15, 2020 Share Posted August 15, 2020 Is arduino also the name of your table? I suggest naming everything different, i.e. use one name for your ODBC data source name, another for the database name, and another for your any tables. Then it won't get confusing. In general, if queries don't work, I usually suggest going into the database's prompt and trying it manually through their SQL tool. But in your case, the issue almost certainly is the table name since it is a very simple query. Quote Link to comment Share on other sites More sharing options...
urdey Posted August 16, 2020 Author Share Posted August 16, 2020 Hi Thanks for the reply I can open Db but I want to read from MySQL and display Temperature and humidity in page. Temperature and humidity is an integer . Daqfactory can read charor varchar from MySQL so how to display the content in page. //how to update a record in MYSQL private dbase = db.Open("arduino") private result = db.QueryToClass(dbase,"select * from dht11_logs;") db.execute(dbase,"update dht11_logs set temperature = 50") db.execute(dbase, "update dht11_logs set humidity=32") try private dbase = db.Open("arduino") private result = db.QueryToClass(dbase,"select * from dht11_logs;") db.execute(dbase,"update dht11_logs set temperature = 90") db.execute(dbase,"update dht11_logs set humidity=0" global datain = db.QueryToClass(dbase,'select * from dht11_logs;') global string dht11_logs = datain.content ?"Getting sucessfully !" db.Close(dbase) catch () ?"Fail to connect!" endcatch Waiting at your earliest. Regards Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 16, 2020 Share Posted August 16, 2020 I'm sorry, but you aren't really giving me enough information to help. I need to know the name of the ODBC data source, the name of the table, and the structure of the table. Is "content" a field in the table? My guess is that line 23 should be datain.temperature, but I can't tell without knowing more detail. Also, pretty much always put: ? strLastError inside of a catch() so you know exactly where the error is. Just putting ? "fail to connect" doesn't tell you which line it had a problem with. My guess is that it is line 23, since you got through the first four lines of script outside the try/catch without error. Also: you only need to open the database once. Do it in a startup sequence, making "dbase" into a global. Opening it multiple times without closing will eventually use up all the available handles. Quote Link to comment Share on other sites More sharing options...
urdey Posted August 16, 2020 Author Share Posted August 16, 2020 Hi Good morning Sir Thanks for your reply.In MySQL Arduino is the SQL database dht11_log is the sensor and column temperature, humidity, and timestamp are stored in SQL format. I want to display individual parameter temperature , humidity, and timestamp in DAQFACTORY Page as shown in the attachment. Waiting at your earliest convenience. Best Regards UDEY Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 16, 2020 Share Posted August 16, 2020 They are the same because you are putting the two different results into the same global variable, dht11_logs. You need to use a separate variable for each. Also they do not need to be strings, and would be better if not. 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.