SQLiteDatabase.OpenBlob

From Xojo Documentation


Method

SQLiteDatabase.OpenBlob(tableName As String, columnName As String, row As UInt64, readWrite As Boolean, databaseName As String = "") As SQLiteBlob

Supported for all project types and targets.

Opens a BLOB column for the specified table and column at the specified row (rowID).

Notes

  • The row parameter is the rowid value, and not the actual row number, for example if you only have one record in your database, with a rowid of 100 then you would pass in a row of 100 and not 1 for example.
  • Pass in false as the readWrite parameter to open the blob for reading only.
  • The blob cannot be resized
  • Creating a new blob automatically zeros the entire blob
  • The row must exist when calling CreateBlob, it does not create a new record for you

Example

This example reads the Logo (stored as a binary picture) from the Logo column for rowID = 1 in the Team table:

Var blob As SQLiteBlob
blob = db.OpenBlob("Team", "Logo", 1, True)
If blob <> Nil Then
Var data As String
While Not blob.EOF
data = data + blob.Read(1000)
If blob.ReadError Then
MsgBox("Error reading from BLOB.")
Exit While
End If
Wend
blob.Close
// Do something with the data
End If

See Also

SQLiteBlob, SQLiteDatabase.CreateBlob