0% found this document useful (0 votes)
609 views

Blob Image Into Picture Box - VB Dot NET Forum

I hav e oracle database table name MINE with blob column. I'm try to get this blob to display into picturebox. The connection into database already done, but the image still not display.

Uploaded by

ghumto86
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
609 views

Blob Image Into Picture Box - VB Dot NET Forum

I hav e oracle database table name MINE with blob column. I'm try to get this blob to display into picturebox. The connection into database already done, but the image still not display.

Uploaded by

ghumto86
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Page 1 of 1

Display long raw / blob image into picturebox get blob/long raw image from oracle database
kerek2
Post ed 1 1 Febr u a r y 2 0 0 9 - 0 3 :1 4 A M

Hi A lls, I'm really need the help regarding this method, actually i hav e oracle database table name MINE with BLOB column . I'm try to get this blob to display into Picturebox 1 . The connection into database already done, but the image still not display ...any one can help me plz.....tq

Brian
Post ed 1 3 A pr il 2 0 0 9 - 1 1 :0 6 A M

A ssuming y ou are using Sy stem.Data.OracleClient, y ou can do the following. (A lso using V B2008 Ex press and Oracle XE on my box ) Dim cn A s New OracleClient.OracleConnection Dim sqlGetBlob A s String = "select bb from big_blobs where blob_id = 1 " Dim command As OracleClient.OracleCommand Dim dr As OracleClient.OracleDataReader Dim b As OracleLob cn.ConnectionString = LocalDbConnectString() command = New OracleCommand(sqlGetBlob, cn) Try cn.Open() dr = command.Ex ecuteReader While dr.Read ' GetOracleLob(i As Integer), this is the column number in the dataset. b = dr.GetOracleLob(0) End While ' Creates an in memory stream Dim ms A s New Memory Stream ' Fill the stream with the blob data ms.Write(b.V alue, 0, b.Length) ' Create an image from the stream Dim img A s Image = Image.FromStream(ms) ' Use the image in y our application pBox .Image = img ' Clean up img = Nothing ms = Nothing Catch ex As Ex ception Finally If cn.State = ConnectionState.Open Then cn.Close()

End If dr = Nothing command = Nothing cn = Nothing End Try

Take notice of 'Dim m s As New Mem ory Stream ' since we are reading the blob from Oracle, we want the BLOB to just be in memory instead of being written to disk. The nex t key item is 'Dim im g As Im age = Im age.From Stream (m s)'. Here is where the BLOB is conv erted to an image. Once y ou hav e the image it can be assigned as such 'pBox .Im age = im g'. Regards, Page 1 of 1
Powered By IP.Board 2 01 1 IPS, Inc.

You might also like