Android Question JDBC MySQL

gbzrope

Member
Licensed User
Is there any way to validate that an INSERT query was succesfull on a remote MySQL database?
Other than to then run another query to retrieve the recordset created?

e.g.
B4X:
sSQL="INSERT INTO statements_collected(ID, Client, DeviceID) VALUES(" & Crsr.getint("ID") & "," & Main.iUserID & ",'" & MainOptions.sDeviceID & "')"
                    mysql.ExecNonQuery(sSQL)
 

gbzrope

Member
Licensed User
1. It is a mistake to use the non-async methods with JdbcSQL.
2. Check the Success parameter. If it is true then the command was executed successfully.

I tried ExecQueryAsync but that expects a recordset, this is just an Insert query, and ExecQueryAsync does not work.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

gbzrope

Member
Licensed User
https://www.b4x.com/android/help/jdbcsql.html#jdbcsql_execnonquerybatch
B4X:
For i = 1 To 1000
  sql.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
Next
Dim SenderFilter As Object = sql.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
Log("NonQuery: " & Success)

Yes, I have that file, the problem is/was that the queries are quite large and I have already built them up with values.
I have just tried:
sql.AddNonQueryToBatch(sSQL, NULL)
Which seems to work.
 
Upvote 0
Top