我在MySQL DB中有一個名爲「Foto」的字段。這個領域是一個blob。當我使用SQL Server中,下面的代碼工作:VB.NET:從MySQL DB返回一個圖像(blob)
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,產生以下錯誤:無效的參數。
你的「ID」字段是性格?不是數字? – Steve
我的ID字段是整數。 – Pinturikkio