我在 VB.NET 中使用以下代码从 MS ACCESS 数据库中检索具有 OLE OBJECT 类型的图像字段的特定用户图像
Dim strSql As String = ""
'For Image
strSql = "Select pic from emp_tb WHERE userid='" + textbox1.Text + "'"
Dim sqlCmd As New OleDbCommand(strSql, con)
'Get image data from DB
Dim imageData As Byte() = DirectCast(sqlCmd.ExecuteScalar(), Byte())
'Initialize image variable
Dim newImage As Image = Nothing
If Not imageData Is Nothing Then
'Read image data into a memory stream
Using ms As New MemoryStream(imageData, 0, imageData.Length)
ms.Write(imageData, 0, imageData.Length)
'Set image variable value using memory stream.
newImage = Image.FromStream(ms, True)
End Using
End If
我将它检索到图片框
picturebox1.image=newImage
我的错误:
第 300 行是
newImage = Image.FromStream(ms, True)
但是我收到错误消息“参数无效”。请帮助我如何使用参数来避免 sql 注入以及如何解决此错误......