我使用此代碼來檢索我的圖片,它正常工作與一個簡單的表,只包含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 –
如果我刪除捕獲我沒有得到錯誤,沒有結果... –