dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleDataReader Class / GetOracleLob Method / GetOracleLob(Int32) Method
The zero-based column ordinal.
Example

In This Topic
    GetOracleLob(Int32) Method
    In This Topic
    Gets the value of the specified column as a OracleLob object.
    Syntax
    'Declaration
     
    Public Overloads Function GetOracleLob( _
       ByVal i As Integer _
    ) As OracleLob
    public OracleLob GetOracleLob( 
       int i
    )

    Parameters

    i
    The zero-based column ordinal.

    Return Value

    The value of the specified column as a OracleLob object.
    Remarks

    Refer to "Working with BLOB and CLOB Data" article for detailed information.

    Example
    This example shows how to download a LOB field from a table using GetOracleLob method.
    public void DownloadLob(OracleConnection myConnection)
    {
      OracleCommand myCommand = new OracleCommand("SELECT * FROM Test.Pictures", myConnection);
      myConnection.Open();
      OracleDataReader myReader = myCommand.ExecuteReader(System.Data.CommandBehavior.Default);
      try
      {
        while (myReader.Read())
        {
          OracleLob myLob = myReader.GetOracleLob(myReader.GetOrdinal("Picture"));
          if(!myLob.IsNull)
          {
            string FN = myReader.GetString(myReader.GetOrdinal("PicName"));
            FileStream fs = new FileStream("D:\\Tmp\\"+FN+".bmp", FileMode.Create);
            BinaryWriter w = new BinaryWriter(fs);
            w.Write(myLob.Value);
            w.Close();
            fs.Close();
            Console.WriteLine(FN+" downloaded.");
          }
        }
      }
      finally
      {
        myReader.Close();
        myConnection.Close();
      }
    }
    Public Sub DownloadLob(ByVal myConnection As OracleConnection)
      Dim myCommand As New OracleCommand("SELECT * FROM Test.Pictures", myConnection)
      myConnection.Open()
      Dim myReader As OracleDataReader = myCommand.ExecuteReader(System.Data.CommandBehavior.Default)
      Try
        While myReader.Read()
          Dim myLob As OracleLob = myReader.GetOracleLob(myReader.GetOrdinal("Picture"))
          If Not myLob.IsNull Then
            Dim FN As String = myReader.GetString(myReader.GetOrdinal("PicName"))
            Dim fs As FileStream = New FileStream("D:\Tmp\" + FN + ".bmp", FileMode.Create)
            Dim w As BinaryWriter = New BinaryWriter(fs)
            w.Write(myLob.Value)
            w.Close()
            fs.Close()
            Console.WriteLine(String.Concat(FN, " downloaded."))
          End If
        End While
      Finally
        myReader.Close()
        myConnection.Close()
      End Try
    End Sub
    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