不更新数据库中的图像 [英] Not updating image in database
本文介绍了不更新数据库中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有收到错误,我已经重新检查了我放的列名,但它仍然没有更新。我的代码有什么问题吗?
我尝试了什么:
I'm not getting errors and I have already rechecked the column names that I put but it's still not updating. Is there something wrong in my code?
What I have tried:
sqlCon.Open();
SqlCommand cmd = new SqlCommand("Update SMStocksTb Set SmStockImage=@SmStockImage where SmStockId=@SmStockId",sqlCon);
MemoryStream stream = new MemoryStream();
pbxUpdateImg.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] pic = stream.ToArray();
cmd.Parameters.AddWithValue("@SmStockId", SmStockId);
cmd.Parameters.AddWithValue("@SmStockImage", pic);
cmd.ExecuteNonQuery();
sqlCon.Close();
推荐答案
检查您传递的 SmStockId
值 - 如果是并不完全符合您的想法,那么它要么与您认为的行不匹配,要么与任何行都不匹配。
Check the SmStockId
value you pass - if it isn't exactly what you think it is, then it either won't match the row you think it does, or it will not match any rows.
这篇关于不更新数据库中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文