dotConnect for SQLite Documentation
Devart.Data.SQLite Namespace / SQLiteDataReader Class / GetSQLiteBlob Method / GetSQLiteBlob(String) Method
The name of the column to get value of.
Example

On this page
    GetSQLiteBlob(String) Method
    On this page
    Gets the value of the specified column as a SQLiteBlob object.
    Syntax
    'Declaration
     
    Public Overloads Function GetSQLiteBlob( _
       ByVal name As String _
    ) As SQLiteBlob
    public SQLiteBlob GetSQLiteBlob( 
       string name
    )

    Parameters

    name
    The name of the column to get value of.

    Return Value

    The value of the specified column as a SQLiteBlob object.
    Example
    This example shows how to download a BLOB field from a table using GetSQLiteBlob method.
    public void DownloadBlob(SQLiteConnection sqLiteConnection)
    {
      SQLiteCommand sqLiteCommand = new SQLiteCommand("SELECT * FROM Pictures", sqLiteConnection);
      sqLiteConnection.Open();
      SQLiteDataReader sqLiteReader = sqLiteCommand.ExecuteReader(System.Data.CommandBehavior.Default);
      try
      {
        while (sqLiteReader.Read())
        {
          SQLiteBlob myBlob = sqLiteReader.GetSQLiteBlob(sqLiteReader.GetOrdinal("Picture"));
          if(!myBlob.IsNull)
          {
            string FN = sqLiteReader.GetString(sqLiteReader.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
      {
        sqLiteReader.Close();
        sqLiteConnection.Close();
      }
    }
    Public Sub DownloadBlob(ByVal sqLiteConnection As SQLiteConnection)
      Dim sqLiteCommand As New SQLiteCommand("SELECT * FROM Pictures", sqLiteConnection)
      sqLiteConnection.Open()
      Dim sqLiteReader As SQLiteDataReader = sqLiteCommand.ExecuteReader(System.Data.CommandBehavior.Default)
      Try
        While sqLiteReader.Read()
          Dim myBlob As SQLiteBlob = sqLiteReader.GetSQLiteBlob(sqLiteReader.GetOrdinal("Picture"))
          If Not myBlob.IsNull Then
            Dim FN As String = sqLiteReader.GetString(sqLiteReader.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
        sqLiteReader.Close()
        sqLiteConnection.Close()
      End Try
    End Sub
    See Also