GetSQLiteBlob(String) Method
Gets the value of the specified column as a
SQLiteBlob object.
'Declaration
Public Overloads Function GetSQLiteBlob( _
ByVal As String _
) As SQLiteBlob
Parameters
- name
- The name of the column to get value of.
Return Value
The value of the specified column as a
SQLiteBlob object.
This example shows how to download a BLOB field from a table using
GetSQLiteBlob method.
public void DownloadBlob(SQLiteConnection sqConnection)
{
SQLiteCommand sqCommand = new SQLiteCommand("SELECT * FROM Pictures", sqConnection);
sqConnection.Open();
SQLiteDataReader sqReader = sqCommand.ExecuteReader(System.Data.CommandBehavior.Default);
try
{
while (sqReader.Read())
{
SQLiteBlob myBlob = sqReader.GetSQLiteBlob(sqReader.GetOrdinal("Picture"));
if(!myBlob.IsNull)
{
string FN = sqReader.GetString(sqReader.GetOrdinal("PicName"));
FileStream fs = new FileStream("D:\\Tmp\\"+FN+".bmp", FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);
w.Write(myBlob.Value);
w.Close();
fs.Close();
Console.WriteLine(FN+" downloaded.");
}
}
}
finally
{
sqReader.Close();
sqConnection.Close();
}
}
Public Sub DownloadBlob(ByVal sqConnection As SQLiteConnection)
Dim sqCommand As New SQLiteCommand("SELECT * FROM Pictures", sqConnection)
sqConnection.Open()
Dim sqReader As SQLiteDataReader = sqCommand.ExecuteReader(System.Data.CommandBehavior.Default)
Try
While sqReader.Read()
Dim myBlob As SQLiteBlob = sqReader.GetSQLiteBlob(sqReader.GetOrdinal("Picture"))
If Not myBlob.IsNull Then
Dim FN As String = sqReader.GetString(sqReader.GetOrdinal("PicName"))
Dim fs As FileStream = New FileStream("D:\Tmp\" + FN + ".bmp", FileMode.Create)
Dim w As BinaryWriter = New BinaryWriter(fs)
w.Write(myBlob.Value)
w.Close()
fs.Close()
Console.WriteLine(String.Concat(FN, " downloaded."))
End If
End While
Finally
sqReader.Close()
sqConnection.Close()
End Try
End Sub