Sub SaveToMySQL
Dim param, value As String
param = "name,Punkte"
value=""
value=value & "'" & myname & "',"
value=value & "'" & intPunkte & "'"
ProgressDialogShow("Insert daten...")
ExecuteRemoteQuery("?insert=true","INSERT INTO myTable (" & param & ") VALUES (" & value & ")",idInsert)
End Sub
Sub ReadFromSQL
ProgressDialogShow("Select daten...")
ExecuteRemoteQuery("?select=true","SELECT * FROM myTable", idSelect)
End Sub
Sub UpdateMySQL
Dim par As String=""
par=""
par=par & "name='" & myname & "',"
par=par & "Punkte='" & intPunkte & "'"
ProgressDialogShow("UPDATE daten...")
ExecuteRemoteQuery("","UPDATE myTable SET " & par & " WHERE id='" & user_id & "'",idUpdate)
End Sub
Sub ExecuteRemoteQuery(exQuery As String,Query As String, TaskId As Int)
Dim req As HttpRequest
req.InitializePost2("http://www.myHomepage.de/datei.php" & exQuery, Query.GetBytes("UTF8"))
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
ProgressDialogHide
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim parser As JSONParser
Dim res As String
res = Response.GetString("UTF8")
Log("Response from server: " & res)
ProgressDialogHide
Select TaskId
Case idInsert
If res>0 Then
user_id=res
ToastMessageShow("Spielstand gesichert!",False)
End If
Case idSelect
Dim l As List
parser.Initialize(res)
l = parser.NextArray
If l.Size = 0 Then
Msgbox("N/A","Test-1")
Else
Msgbox("N/A","Test-2")
Dim m As Map
m = l.Get(0)
'....
End If
Case idUpdate
If res>0 Then
ToastMessageShow("Spielstand Updatet!",False)
End If
End Select
Response.Release
End Sub