carlos7000 Well-Known Member Licensed User Longtime User Jul 9, 2019 #1 Hi all. I'm trying to save some of the data I get from the gps in a database. With the following code I have no problems. Code: Query = "INSERT INTO `GpsData`(`Id`,`UnixTime`,`Lat`,`Lon`,`Speed`,`Bearing`) VALUES (NULL,'" & UnixTime & "','" & Lat & "','" & Lon & "','" & Speed & "','" & Bearing & "');" Sql1.ExecNonQuery(Query) Unfortunately the code runs very slow. On average it takes 1 second to execute. Looking for ways to improve performance I wrote this new code: Code: Sql1.BeginTransaction Sql1.ExecNonQuery2("INSERT INTO GpsData VALUES(NULL,?,?,?,?,?)", Array As String(UnixTime, Lat, Lon, Speed, Bearing)) Sql1.EndTransaction The code runs quickly. On average, the execution time is 50 thousandths of a second, but when reviewing the database, there is no data. Neither on the phone nor in the log, there is a message of any error. What could be the problem?
Hi all. I'm trying to save some of the data I get from the gps in a database. With the following code I have no problems. Code: Query = "INSERT INTO `GpsData`(`Id`,`UnixTime`,`Lat`,`Lon`,`Speed`,`Bearing`) VALUES (NULL,'" & UnixTime & "','" & Lat & "','" & Lon & "','" & Speed & "','" & Bearing & "');" Sql1.ExecNonQuery(Query) Unfortunately the code runs very slow. On average it takes 1 second to execute. Looking for ways to improve performance I wrote this new code: Code: Sql1.BeginTransaction Sql1.ExecNonQuery2("INSERT INTO GpsData VALUES(NULL,?,?,?,?,?)", Array As String(UnixTime, Lat, Lon, Speed, Bearing)) Sql1.EndTransaction The code runs quickly. On average, the execution time is 50 thousandths of a second, but when reviewing the database, there is no data. Neither on the phone nor in the log, there is a message of any error. What could be the problem?
Geezer Active Member Licensed User Longtime User Jul 9, 2019 #2 You're missing the TransactionSuccessful before you end it. Upvote 0
carlos7000 Well-Known Member Licensed User Longtime User Jul 9, 2019 #3 doing so? Code: Sql1.BeginTransaction Sql1.ExecNonQuery2("INSERT INTO GpsData VALUES(NULL,?,?,?,?,?)", Array As String(UnixTime, Lat, Lon, Speed, Bearing)) Sql1.TransactionSuccessful Sql1.EndTransaction Upvote 0
doing so? Code: Sql1.BeginTransaction Sql1.ExecNonQuery2("INSERT INTO GpsData VALUES(NULL,?,?,?,?,?)", Array As String(UnixTime, Lat, Lon, Speed, Bearing)) Sql1.TransactionSuccessful Sql1.EndTransaction
Geezer Active Member Licensed User Longtime User Jul 9, 2019 #4 Yes. If you use a transaction but don't mark it as successful, the data is ignored. Upvote 0
carlos7000 Well-Known Member Licensed User Longtime User Jul 9, 2019 #5 Geezer said: Yes. If you use a transaction but don't mark it as successful, the data is ignored. Click to expand... I can not believe I forgot that line. The speed improved to 700 miles per second, but it is still very slow. Very thanks. Upvote 0
Geezer said: Yes. If you use a transaction but don't mark it as successful, the data is ignored. Click to expand... I can not believe I forgot that line. The speed improved to 700 miles per second, but it is still very slow. Very thanks.
Erel B4X founder Staff member Licensed User Longtime User Jul 10, 2019 #6 Sounds like you are doing something wrong. Post all the relevant code. Upvote 0