We help IT Professionals succeed at work.
Get Started

Display oracle binary file

452 Views
Last Modified: 2013-11-26
I'm new on ASP.net. For now all I want is to create a page with a textbox, a button, and a place to display an image. The code below I use for any windows applications & works fine, but I'm very confuse on how to display it on a web page using Response.ContentType = "image/jpeg"
                    Response.BinaryWrite
Thanks.
Private Sub RetriveImage()
        Dim sqlCommand As String = ""
        Dim oCon As OracleConnection = New OracleConnection("user id = fooo;password = foo;data source = FOO.WORLD;")
        Dim cmd = New OracleCommand(sqlCommand, oCon)
        Dim oraReader As OracleDataReader
        Dim id As String = ""
 
        Try
 
            oCon.Open()
            sqlCommand = "SELECT ID_NMBR, SGNTRE FROM VO_SGNTRE WHERE ID_NMBR = 1111" '& Me.TextBox1.Text
            Dim oraImgCmd As OracleCommand = New OracleCommand(sqlCommand, oCon)
 
            oraImgCmd.InitialLONGFetchSize = 14000
            oraImgCmd.CommandType = CommandType.Text
 
            oraReader = oraImgCmd.ExecuteReader()
            While oraReader.Read
 
                '// If Photo exists in the Database, load it into the PictureBox
                If (oraReader.GetValue(1).ToString() <> "") Then
                   
                    '// Fetch the BLOB data through OracleDataReader using OracleBlob type
                    Dim blob As OracleBinary = oraReader.GetOracleBinary(1)
 
                    '// Create a byte array of the size of the Blob obtained
                    Dim byteArr As Byte() = New Byte(blob.Length) {}
 
                    '// Read blob data into byte array
                    'Dim i As Integer = blob.Read(byteArr, 0, System.Convert.ToInt32(blob.Length))
                    Dim i As Long = oraReader.GetBytes(1, 0, byteArr, 0, blob.Length)
                   
                    '// Get the primitive byte data into in-memory data stream
                    Dim memStream As MemoryStream = New MemoryStream(byteArr)
 
                    
                    '// Attach the in-memory data stream to the PictureBox
                    'Me.picSOEimage.Image = Image.FromStream(memStream)
 
                    '// Fit the image to the PictureBox size
                    Me.picSOEimage.SizeMode = PictureBoxSizeMode.StretchImage
 
                                        'System.Windows.Forms.Application.DoEvents()
 
                Else
                    'MessageBox.Show("1  SNTRE not found  " & oraReader.GetValue(2).ToString())
                End If
 
                'System.Windows.Forms.Application.DoEvents()
            End While
 
            oraReader.Close()
 
        Catch ex As Exception
            MessageBox.Show(sqlCommand & vbCrLf & ex.Message)
        Finally
            oCon.Close()
        End Try
 
 
    End Sub

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE