I have an SQLite 3 table that contains various fields including a field of type 'Picture'. Naturally, trying to load all the fields with 'SELECT * FROM MyTable' defines a huge Cursor object and slows any device down to a crawl so it is to be avoided. Using a cursor object to retrieve a single record dataset and display by the following code works but seems cumbersome:
For more compact code I tried using:
Unfortunately it throws an exception as the var Buffer cannot accept the Picture field object without defining a Cursor and using the Cursor.GetBlob method.
Is there a correct way of employing SQL.ExecQuerySingleResult() here ?
B4X:
Cursor1 = SQL.ExecQuery("SELECT Picture1 FROM MyTable WHERE rowid = 99")
Cursor1.Position = 0
Dim Buffer() As Byte
Buffer = Cursor1.GetBlob("Picture1")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1)
InputStream1.Close
imgPicture.Bitmap= Bitmap1
For more compact code I tried using:
B4X:
Buffer = SQL.ExecQuerySingleResult("SELECT Picture1 FROM MyTable WHERE rowid = 99")
Unfortunately it throws an exception as the var Buffer cannot accept the Picture field object without defining a Cursor and using the Cursor.GetBlob method.
Is there a correct way of employing SQL.ExecQuerySingleResult() here ?