Use the new JRDC2 as told by Erel then change the GetAnimal sub to something like this:
B4X:
Sub GetAnimal(id As Int)
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_app", Array(id))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone (j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
'For Each row() As Object In res.Rows
' EditText2.Text = row(res.Columns.Get("name"))
' EditText3.Text = row(res.Columns.Get("kg"))
'Next
Dim row() As Object = res.Rows.Get(0)
EditText2.Text = row(res.Columns.Get("name"))
EditText3.Text = row(res.Columns.Get("kg"))
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
Use the new JRDC2 as told by Erel then change the GetAnimal sub to something like this:
B4X:
Sub GetAnimal(id As Int)
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_app", Array(id))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone (j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
'For Each row() As Object In res.Rows
' EditText2.Text = row(res.Columns.Get("name"))
' EditText3.Text = row(res.Columns.Get("kg"))
'Next
Dim row() As Object = res.Rows.Get(0)
EditText2.Text = row(res.Columns.Get("name"))
EditText3.Text = row(res.Columns.Get("kg"))
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
[/引用]
Hi thank you
You know me
but have some Report an error
I'm use MSSsql ,Not mysql,Is it related to this?
How to change
please
Yes,I make a mistake ,I relearned “ JRDC2-B4J”,
and now,It's successful ,Thank you very very much!
But there is no update process in the example ,I tried to write it by myself,But i'm failed again
in config.properties:
B4X:
sql.update_app=update app set kg=? where id=?
B4X:
Sub UpdateRecord(kg As String,id As Int)
Dim cmd As DBCommand = CreateCommand("update_app", Array(kg,id))
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log("Inserted successfully!")
Else
Log("error:" & j.ErrorMessage)
End If
j.Release
End Sub
Sub Button2_Click
UpdateRecord(EditText3.Text,EditText1.Text )
End Sub