我在 MySQL DB 中有一个名为“Foto”的字段。该字段是一个 blob。当我使用 SQL Server 时,以下代码有效:
Dim conn As New MySqlConnection
conn.ConnectionString = ConnectionString
Dim cmd As New MySqlCommand
cmd.Connection = conn
conn.Open()
cmd.CommandText = "SELECT Foto FROM MyTable WHERE ID = '" & IDtxt.ToString & "'"
Dim reader As MySqlDataReader
reader = cmd.ExecuteReader
While reader.Read
If (IsDBNull(reader("Foto"))) Then
frmCartaIdentitaView.pctImage.Image = Nothing
Else
Dim byteImage() As Byte = reader("Foto")
Dim frmImageView stmFoto As New System.IO.MemoryStream(byteImage)
frmImageView.pctImage.Image = Image.FromStream(stmFoto)
frmImageView.pctImage.SizeMode = PictureBoxSizeMode.Zoom
frmImageView.Show()
End If
End While
但是现在我使用的是mysql,会产生以下错误:参数无效。