Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing Variables to mySQL DB

Can anyone explain to me how I can write the data from variables into a mySQL Database table?  I have a SQLExec object created and can use the object to manually write text values to my table, but I am unsure of the syntax to use to write the actual values from an alias I have tied back to a Modbus register.  The Modbus object is named Modbus1 and the alias is tied to a scaled decimal value and is named test.  Here is an example of the SQL statement I am using: 

"INSERT INTO testtable (Name, Age) VALUES('sam', Modbus1.test)" 
 
These are simply test values and have no real use for my actual program, but if I can get these working I will be able to complete my program.  Here is the error I receive when executing the SQL statement:
 
[Not Buffered] S0022/1054: [MySQL][ODBC 3.51 Driver][mysqld-5.0.37-community-nt]Uknown column 'Modbus1.test' in 'field list'.
 
Any assitance or direction you can offer me in getting the values of my variable to write to the table would be appreciated. 
0 Kudos
Message 1 of 7
(5,524 Views)

The following link may help:

http://digital.ni.com/public.nsf/allkb/4ADEEA04CD24AE0B862565E20002A16F

If the MySQL table and ODBC driver are setup correctly the SQLExec object will use the same SQL syntax.

Message 2 of 7
(5,522 Views)
Thank you for your input.  This allowed me to write the values to the db as I hoped.  Where is the text() function coming from?  Is it native to Lookout or to mySQL?
0 Kudos
Message 3 of 7
(5,519 Views)
The text function is a native Lookout function.  You can find more information about this function and other Lookout functions in the Lookout Help.
0 Kudos
Message 4 of 7
(5,516 Views)

I tried using the sqlexec function and it doesn't work. Can somebody tell me how this actually works from beginning to end. I want to send data to mysql database. Thanks.

 

Robert

0 Kudos
Message 5 of 7
(4,552 Views)

Here is the lookout source file based this issue:

 

 

0 Kudos
Message 6 of 7
(4,531 Views)

Robert, please post in your thread:   http://forums.ni.com/ni/board/message?board.id=190&thread.id=7348

 

Thanks,

Mike 

-----------------------------------------------------------------------
Forshock - Consult.Develop.Solve.
0 Kudos
Message 7 of 7
(4,529 Views)