Loading Byte data from database file
I am using following code to get data from database and load to picture box
Dim vrPicFromDB = IO.File.ReadAllBytes(DsPic.tblPicTest.Item("Picture"))
Dim ms As New MemoryStrea开发者_运维问答m(vrPicFromDB)
PictureBox1.Image = Image.FromStream(ms)
It gives error on DsPic.tblPicTest.Item("Picture")) portion of the statement. I also tried
CByte(DsPic.tblPicTest.Item("Picture")))
but it gives the same error.
Please advise how to fix it. Thanks Furqan
Assuming that the "Picture" column is an Image column in the database, your line to load the vrPicFromDB byte array will look something like this:
Dim vrPicFromDB As Byte()
vrPicFromDB = CType(DsPic.tblPicTest.Rows(0).Item("Picture"), Byte())
That line assume you have loaded at least 1 row of data.
精彩评论