Sub SaveOne(Item As Inspection)
Dim db1 As DB
db1.Initialize
Dim sql1 As SQL = db1.Open
If Item.InspectionId=0 Then
Log("INSERT")
'Autokey
sql1.ExecNonQuery2("INSERT INTO Inspection (Title) VALUES (?);", Array As Object("New") )
Item.InspectionId = sql1.ExecQuerySingleResult("SELECT last_insert_rowid() FROM Inspection")
Log ("New InspectionId = " & Item.InspectionId)
End If
Log("UPDATE")
Dim arg As List
arg = Array As Object( _
Item.InspectionId, Item.Title, Item.Description, Item.Notes, Item.Customer, _
Item.Project, Item.Order, _
Item.OrderPos, Item.Name, _
Item.Address, Item.Zip, _
Item.City, Item.State, _
Item.Country, Item.Latitude, _
Item.Longitude, Item.IsGPSCoordinates, _
Item.Date, Item.AppId )
' without '' at strings!!! just ? as parameter !!!
sql1.ExecNonQuery2("UPDATE Inspection SET InspectionId=?, Title=?, Description=?, Notes=?, Customer=?, Project=?, [Order]=?, OrderPos=?, Name=?, Address=?, Zip=?, City=?, State=?, Country=?, Latitude=?, Longitude=?, IsGPSCoordinates=?, Date=?, AppId=? WHERE InspectionId=" & Item.InspectionId, arg)
db1.Close
End Sub