Difference between revisions of "SQLiteDatabase.OpenBLOB"

From Xojo Documentation

 
Line 1: Line 1:
 
<ShowIf version=2013r1>
 
<ShowIf version=2013r1>
 
{{MethodBox
 
{{MethodBox
| name=OpenBlob
+
| name=OpenBLOB
 
| owner=[[SQLiteDatabase]]
 
| owner=[[SQLiteDatabase]]
 
| ownertype=class
 
| ownertype=class
 
| scope=public
 
| scope=public
 
| parameters=tableName As String, columnName As String, row As UInt64, readWrite As Boolean, databaseName As String = ""
 
| parameters=tableName As String, columnName As String, row As UInt64, readWrite As Boolean, databaseName As String = ""
| returntype=[[SQLiteBlob]]
+
| returntype=[[SQLiteBLOB]]
 
| platform=all
 
| platform=all
 
}}
 
}}
Line 30: Line 30:
 
     data = data + blob.Read(1000)
 
     data = data + blob.Read(1000)
 
     If blob.ReadError Then
 
     If blob.ReadError Then
       MsgBox("Error reading from BLOB.")
+
       MessageBox("Error reading from BLOB.")
 
       Exit While
 
       Exit While
 
     End If
 
     End If
Line 40: Line 40:
  
 
== See Also ==
 
== See Also ==
[[SQLiteBlob]], [[SQLiteDatabase.CreateBlob]]
+
[[SQLiteBLOB]], [[SQLiteDatabase.CreateBLOB]]
 
</ShowIf>
 
</ShowIf>

Latest revision as of 19:30, 18 February 2022


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
MessageBox("Error reading from BLOB.")
Exit While
End If
Wend
blob.Close
// Do something with the data
End If

See Also

SQLiteBLOB, SQLiteDatabase.CreateBLOB