i ave one question:
search row whit item"timestamp" = ? (where ? as blob)
B4X:
Sub SeEsiste(timestamp() As Byte, NomeTab As String) As Boolean
Dim Cursor1 As Cursor
Cursor1=sqlpi.ExecQuery("Select count(*) as tot FROM " & NomeTab & " WHERE timestamp = '" & timestamp & "'" )
Cursor1.Position=0
If Cursor1.GetInt ("tot")>0 Then
Cursor1.Close
Return True
Else
Cursor1.Close
Return False
End If
End Sub
If you insist on using Blob for timestamp, pleas try this code:
B4X:
Sub SeEsiste(timestamp() As Byte, NomeTab As String) As Boolean
Dim tot As Int
tot=sqlpi.ExecQuerySingleResult2("Select count(*) FROM " & NomeTab & " WHERE timestamp = ?", _
Array As Object(timestamp))
If tot =0 Then
Return False
End If
Return True
End Sub
because the sqlite table is synchronized with identical table on Mssql
your code not work (argument 1 has type java.lang.String[], got java.lang.Object[])
thanks
The sqlite interface in B4A is a little different from the sqlite interface from B4J. I'm assuming that the B4A interface (the standard SQL library) is based in Android's SQLiteDatabase class (https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html). The various query methods of that class use a string array for passing on parameters. There are two solutions to this problem:
Note: #1 works because all that is needed is a single result. If the SELECT would return multiple results/multiple rows, this will not work (that is the limitation of the compliedStatement method/SQLiteStatement class).
That's what I did look at (the docs) and in this one instance (returning a long for the COUNT(*)), a SELECT would (yes, I'm guessing here) work with compileStatement. You have to combine it with the bindBlob method to pass on the Blob's byte array. SQLiteStatement's simpleQueryForLong method (https://developer.android.com/refer...ite/SQLiteStatement.html#simpleQueryForLong()) actually mentions the SELECT COUNT(*) case.