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.

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)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.