我使用此代码来检索我的图片,它正常工作与一个简单的表,只包含blob,但是当我试图适应它为我的表用户containt(cin,nom, prenom ....,图像)异常指示从MySQL数据库检索blob图片c#
“Paramétre非有效”(不是一个有效参数)
int bufferSize = 1000;
try
{
string SQL = "Select image from user ";
MySqlCommand cmd = new MySqlCommand(SQL, db.Connection);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "image");
int c = ds.Tables["image"].Rows.Count;
db.CloseConnection();
if (c > 0)
{
Byte[] byteBLOBData = new Byte[bufferSize];
byteBLOBData = (Byte[])(ds.Tables["image"].Rows[c - 1]["image"]);
MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
pictureBox1.Image = Image.FromStream(stmBLOBData);
MessageBox.Show("bien chargée");
}
}
catch (Exception ex)
{
MessageBox.Show("Connection Error!\n" + ex.Message, "Error Message",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
在哪一行出现异常? – Gusman
我认为你不必填写数据集,但直接使用SqlDataReader –
如果我删除捕获我没有得到错误,没有结果... –