Hello, I'm trying to read data from my SQL cells. My table from phpMyAdmin looks like this:
My code looks like this:
B4X:
Sub SQL_Read
Try
Dim RS As ResultSet
RS = SQL1.ExecQuery("SELECT 'bot' FROM `bot_settings`")
Do While RS.NextRow
Log(RS.GetString("bot"))
Loop
Catch
Log(LastException)
End Try
End Sub
Don't forget to close your cursor after finishing your read:
B4X:
Sub SQL_Read
Try
Dim RS As ResultSet
RS = SQL1.ExecQuery("SELECT 'bot' FROM `bot_settings`")
Do While RS.NextRow
Log(RS.GetString("bot"))
Loop
RS.Close '<--- Here
Catch
Log(LastException)
End Try
End Sub
Apparently he is using MySQL. The commands are different between SQLite and MySQL.
You can also try this website: http://www.w3schools.com/sql/default.asp and all the keywords are given in the left column. You should try them one by one and you'll learn fast.
Don't forget to close your cursor after finishing your read:
Apparently he is using MySQL. The commands are different between SQLite and MySQL.
You can also try this website: http://www.w3schools.com/sql/default.asp and all the keywords are given in the left column. You should try them one by one and you'll learn fast.
You're right, I ran into "read only" errors while trying to update. Close seemed to fix the problem. That was confusing to me since I write to the data base every 10 seconds I thought I should leave it open but oh well.
By the way, if you have many people connecting to the database, you may be interested in reading a problem I encountered a while ago here: http://www.b4x.com/android/forum/th...ion-not-allowed-after-resultset-closed.42516/
The solution was to use the Pool library from jServer. But maybe that's not a something that will happen to you.