Android Question MySQL Insert INTO dbTable

atiaust

Active Member
Licensed User
Longtime User
Hi All,

I am having problems with a B4A app that inserts records into a MySQL database. I can read the database so the connection is working correctly but when I try to write to the database I get errors with the Insert format and I have no idea why.

B4X:
        Dim dbCount As Double = txtCount.text
        Dim dbLocation As String = txtLocation.text
        Dim dbDate As String = Utils.DateTimeToMysql(DateTime.Now) 'converts DateTime.Now to "YYYY-MM-DD HH:MM:SS" mySQL format
        Log("DBDate = "&dbDate)
        db.ExecuteASync("INSERT INTO stocktake SET stockID="&stockID&", partno="&stkPartNo&", count="&dbCount&", location="&dbLocation&", countdate="&dbDate&";","")

I am using MSMysql in B4A - v1.09. The same INSERT INTO line works in B4J
The logged date string is: DBDate = 2021-07-22 18:00:10
The MySQL field is DATETIME

SqlException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '18:00:10' at line 1

Any help gratefully accepted.
Thanks
 

atiaust

Active Member
Licensed User
Longtime User
Thanks for the reply's.
After further reading I came to the same conclusion and have started converting to JdbcSQL
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…