By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

System.ArgumentException was unhandled Message: Parameter is not valid.

P: 1
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.)

Expand|Select|Wrap|Line Numbers
  1. Dim cn As New OleDb.OleDbConnection
  2. cn.ConnectionString = ""
  3. cn.Open()
  4. Dim arrImage() As Byte
  5. Dim myMS As New IO.MemoryStream
  6. Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM tblRecords " & _
  7. " WHERE ID=" & Me.txtID.Text, cn)
  8. Dim dt As New DataTable
  9. da.Fill(dt)
  10. If dt.Rows.Count > 0 Then
  11. Details.lblId.Text = dt.Rows(0).Item("ID") & ""
  12. Details.txtSpecies.Text = dt.Rows(0).Item("Species") & ""
  13. Details.txtMutation.Text = dt.Rows(0).Item("Mutation") & ""
  14. If Not IsDBNull(dt.Rows(0).Item("photo")) Then
  15. arrImage = dt.Rows(0).Item("photo")
  16. For Each ar As Byte In arrImage
  17. myMS.WriteByte(ar)
  18. Next
  19. Details.picPhoto.Image = System.Drawing.Image.FromStream(myMS) <--- here where i'm having error
  20. End If
  21. Else
  22. MsgBox("Record not found!")
  23. End If
  24. Details.Show()
  25. cn.Close()
  26. End Sub
thank you in advance :)
Sep 23 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.