i am new to vb.net, i have been struggling long days, that how to retrieve image from ms access database..i could successfully insert the image but i'm not able to retrieve it in picture box.
I used following code to insert image:
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
Dim bytImage() As Byte
Try
Dim ms As New System.IO.MemoryStream
Dim bmpImage As New Bitmap(PictureBox3.Image)
PictureBox3.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
bytImage = ms.ToArray()
ms.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim connection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;D ata Source=SVT.accdb;Persist Security Info=False;")
Dim command As New System.Data.OleDb.OleDbCommand("select photo from tutorial where c_num='" & txtcnum.Text & "'", connection)
connection.Open()
Dim pictureData As Byte() = DirectCast(command.ExecuteScalar(), Byte())
connection.Close()
Dim pictures As Image = Nothing
Using stream As New System.IO.MemoryStream(pictureData)
pictures = New System.Drawing.Bitmap(stream)
End Using
PictureBox3.Image = pictures
End Sub
i used the above code only. For retrieve i referred online, in online i got many codes but every codes telling the same error 'Parameter is not valid'. i'm full of headache..please kindly give me any source code for this..i attached screenshot...please refer it. Thank You..
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET. subscribe