asked on
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