我试图将存储在Access数据库中的图像检索到Picturebox。 我对这种语言不是很流利,但我目前的代码如下:
Private Sub lstUsers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstUsers.SelectedIndexChanged
Dim dt As New DataTable
dt = runSQL("Select * from tblUser where UserName = '" & lstUsers.SelectedItem.ToString & "'")
txtForename.Text = dt.Rows(0)(2)
txtSurname.Text = dt.Rows(0)(3)
txtCode.Text = dt.Rows(0)(6)
txtFinish.Text = dt.Rows(0)(7)
Dim data As Byte() = DirectCast(dt.Rows(0)(8), Byte())
Using ms As New MemoryStream(data)
Me.PictureBox1.Image = Image.FromStream(ms)
End Using
End Sub
当我尝试运行它并选择用户名时,我收到以下指向Image.FromStream(ms)的错误消息:
参数无效。
任何帮助都将不胜感激。