Hi everyone i'm using vb 2008 for this project and i'm still not so familiar with it so please help me...
I'm trying to display image from MS Access database to another form picturebox but its not working.
this is the error i always encounter -> (System.ArgumentException was unhandled
Message: Parameter is not valid.)
Dim cn As New OleDb.OleDbConnection
cn.ConnectionString = ""
cn.Open()
Dim arrImage() As Byte
Dim myMS As New IO.MemoryStream
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM tblRecords " & _
" WHERE ID=" & Me.txtID.Text, cn)
Dim dt As New DataTable
da.Fill(dt)
If dt.Rows.Count > 0 Then
Details.lblId.Text = dt.Rows(0).Item("ID") & ""
Details.txtSpecies.Text = dt.Rows(0).Item("Species") & ""
Details.txtMutation.Text = dt.Rows(0).Item("Mutation") & ""
If Not IsDBNull(dt.Rows(0).Item("photo")) Then
arrImage = dt.Rows(0).Item("photo")
For Each ar As Byte In arrImage
myMS.WriteByte(ar)
Next
Details.picPhoto.Image = System.Drawing.Image.FromStream(myMS) <--- here where i'm having error
End If
Else
MsgBox("Record not found!")
End If
Details.Show()
cn.Close()
End Sub
thank you in advance :)