#SQL COMMANDS
sql.update_customers=UPDATE customers SET CustomerId = ?, FirstName = ?, LastName = ?, Company = ?, Address = ?, Email = ? WHERE rowid = ?
Module Class --- > ShowDialog():
Private Sub ShowDialog(Item As Map, RowId As Long, Action As Int)
...
Dim params As List
params.Initialize
'keys based on the template json file
params.AddAll(Array As String(id, Item.Get("FirstName"), Item.Get("LastName"), Item.Get("Company"), Item.Get("Address"), Item.Get("Email")))
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("update_customers", Array As Object(params.Get(0), params.Get(1), params.Get(2), params.Get(3), params.Get(4), params.Get(5), RowId))
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
Wait For (req.ExecuteCommand(cmd,Null)) JobDone(j As HttpJob)
If j.Success Then
TMS.TMessage1_Show("Transaction Successful")
Else
Log("ERROR (7): " & j.ErrorMessage)
TMS.TMessage3_Show( j.ErrorMessage)
End If
j.Release
...
End Sub
Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = Name
If Parameters <> Null Then cmd.Parameters = Parameters
Return cmd
End Sub
Hi,
Well, I encountered an unexpected situation that when using the code:
Dim cmd As DBCommand = CreateCommand ("update_customers", Array As Object (params))
the data was not updated in the database at all.
Only after changing the code to:
Dim cmd As DBCommand = CreateCommand ("update_customers", Array As Object (params.Get (0), params.Get (1), params.Get (2), params.Get (3), params.Get (4), params.Get (5), RowId))
all data changes were correctly saved in the database.
Is there a better solution for substituting parameters for "params"?
Thank you in advance for your suggestion ...