Avatar of soetal1
soetal1 asked on

Display oracle binary file

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"
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 = ""
            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
                    'MessageBox.Show("1  SNTRE not found  " & oraReader.GetValue(2).ToString())
                End If
            End While
        Catch ex As Exception
            MessageBox.Show(sqlCommand & vbCrLf & ex.Message)
        End Try
    End Sub

Open in new window

.NET ProgrammingVisual Basic.NETASP.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy