Hi, I'm using php script referenced in Connect Android to MySQL Database Tutorial to perform querys to a remote mysql database and works fine, but I need also insert multiple records into the database so I used the same php script to send multiple "INSERT" commands, but it wont work for all the records. The code I'm using is something like this:
The log shows this:
The Mysql Table database query show this (image below).
How can i fix this? I need insert properly all the records in the remote mysql database (the order is not a problem) and in a reasonable time.
Thanks in advanced.
B4X:
Sub CmdInserts_Click
Dim numero As Int
Dim Fecha As String , CodCliente As String , CodVendedor As String , Total As Float , Iva As Float
Dim Detalle As String , Estado As Int , Aprobado As Int
HCCabeceraPedidos.Initialize ("HCCabeceraPedidos")
For i=0 To 1000
numero=i
Fecha="2012-01-01"
CodCliente="00000"
CodVendedor="03"
Total=0
Iva=0
Detalle="'prueba ingreso registro"
Estado=0
Aprobado=0
SQL="Insert into pedidocab values('" & numero & "','" & Fecha & "','" & CodCliente & "','" & CodVendedor & "'," &Total & "," &Iva & ",'" &Detalle & "'," & Estado & "," & Aprobado & ")"
Log(SQL)
ExecuteRemoteQuery(SQL,i)
Next
Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
' servertest.com is for example purpose only
req.InitializePost2("http://www.servertest.com/querydat.php", Query.GetBytes("UTF8"))
HCCabeceraPedidos.Execute(req, TaskId)
End If
End Sub
Sub HCCabeceraPedidos_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Log("Insertado" & TaskId)
End Sub
The log shows this:
B4X:
Insert into pedidocab values('0','2012-01-01','00000','03',0,0,'prueba ingreso registro',0,0)
Insert into pedidocab values('1','2012-01-01','00000','03',0,0,'prueba ingreso registro',0,0)
Insert into pedidocab values('2','2012-01-01','00000','03',0,0,'prueba ingreso registro',0,0)
.
.
.
Insert into pedidocab values('1000','2012-01-01','00000','03',0,0,'prueba ingreso registro',0,0)
But the log in the responsesuccess event only show this:
Inserted 1
Inserted 5
Inserted 3
Inserted 2
Inserted 0
Inserted 6
Inserted 52
Inserted 54
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
running waiting messages (5)
(*** after a while ****)
Inserted 7
Inserted 62
Inserted 48
Inserted 63
Inserted 65
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
sending message to waiting queue (hccabecerapedidos_responsesuccess)
running waiting messages (5)
(*** after a while ****)
Inserted 8
Inserted 67
Inserted 57
Inserted 68
Inserted 70
The Mysql Table database query show this (image below).
How can i fix this? I need insert properly all the records in the remote mysql database (the order is not a problem) and in a reasonable time.
Thanks in advanced.