0

Hello,

I have creating my application in visual basic using the tables from ms access that I created. In the tables there is field "attachment" with pictures saved in there.

I want to show this pictures on my vb form. All the records areshowing fine apart from the pictures.

2
Contributors
1
Reply
5
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
1

You have to get an image from database to byte array, and with StreamReader then pass it to pictureBox:

Dim ImageByte As Byte() = Nothing
Dim MemStream As MemoryStream = Nothing
Dim PicBx As New PictureBox()
Dim OB As Object
Dim WorkingDirectory As String = Application.StartupPath + "\"
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & WorkingDirectory & "DBFile.mdb; Persist Security Info=True"
cnction = New OleDbConnection(connString)
cnction.Open()
Dim ImageID As Integer = 6
sqlCommand = "SELECT ImageObject FROM ImagesTable WHERE ImageID = " & ImageID & ""
comm = New OleDbCommand(sqlCommand, cnction)
ImageByte = comm.ExecuteScalar()
MemStream = New MemoryStream(ImageByte)
PictureBox1.Image = Image.FromStream(MemStream)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.