title: Convert retrieved Blob to base64 vb.net
body: <p>I am trying to read blob from oracle database and convert it to base64String then display it in my web page. Reading from oracle is working fine and is returning data, but converting image to base64 is returning huge value (length = 1 600 000 and above) that cannot be converted to image and displayed in my page (a broken icon image is displayed). In other words I implemented a base64String from the internet in my code and everything works properly ... what is the best way to convert my blobs to images ? Below is my code:</p>
  
  <pre><code> Dim Conn As String = ConfigurationManager.ConnectionStrings("connString").ConnectionString
          Dim cnnConnection As New OracleConnection(Conn)
          cnnConnection.Open()
  
          Dim cmd As New OracleCommand()
          cmd.Connection = cnnConnection
          cmd.CommandText = "SELECT d.document_file from T_library_documents d d.library_documents_id=64 ORDER BY d.DOCUMENT_NAME"
          cmd.CommandType = CommandType.Text
  
          Dim dr As OracleDataReader = cmd.ExecuteReader
          If dr.Read() Then
  
              Dim blob As OracleBlob = dr.GetOracleBlob(0)
              Dim byteArr As [Byte]() = New [Byte](blob.Length - 1) {}
              Dim i As Integer = blob.Read(byteArr, 0, System.Convert.ToInt32(blob.Length))
              blob.Close()
              cnnConnection.Close()
  
              Dim imageBase64 As String = Convert.ToBase64String(byteArr)
              Dim imageSrc As String = String.Format("data:image/gif;base64,{0}", imageBase64)
              img.Attributes("src") = imageSrc
          End If 
  </code></pre>