dotConnect for PostgreSQL Documentation
Devart.Data.PostgreSql Namespace / PgSqlBlob Class / Value Property
Example

In This Topic
    Value Property (PgSqlBlob)
    In This Topic
    Gets the value of the PgSqlBlob object.
    Syntax
    'Declaration
     
    Public ReadOnly Property Value As Byte()
    public byte[] Value {get;}

    Property Value

    The value of the PgSqlBlob object.
    Remarks
    Check the IsNull property before reading the Value property to avoid raising an exception.
    Example
    This code fragment downloads a BLOB field from a table to a file. Value property is initialized by calling PgSqlDataReader.GetPgSqlBlob method and then written to a stream.
    PgSqlBlob myBlob = myReader.GetPgSqlBlob(myReader.GetOrdinal("Picture"));
    if(!myBlob.IsNull)
    {
      string FN = myReader.GetString(myReader.GetOrdinal("PicName"));
      FileStream fs = new FileStream("D:\\Tmp\\"+FN+".bmp", FileMode.Create);
      fs.Write(myBlob.Value,0,(int)myBlob.Length);
      fs.Close();
      Console.WriteLine(FN+" downloaded.");
    }
    Dim myBlob As PgSqlBlob = myReader.GetPgSqlBlob(myReader.GetOrdinal("Picture"))
    If Not myBlob.IsNull Then
      Dim FN As String = myReader.GetString(myReader.GetOrdinal("PicName"))
      Dim fs As FileStream = New FileStream("D:\Tmp\" + FN + ".bmp", FileMode.Create)
      fs.Write(myBlob.Value, 0, Convert.ToInt32(myBlob.Length))
      fs.Close()
      Console.WriteLine(String.Concat(FN, " downloaded."))
    End If
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also