我们如何在图片框中应用限制。 [英] How we can apply restriction in picture box.
本文介绍了我们如何在图片框中应用限制。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要当没有选择Image时,则自动将Null Value保存到SQL数据库。我正在使用C#
我尝试了什么:
I want When there is no Image is selected then Automaticly it Save Null Value to SQL database . I'm Using C#
What I have tried:
if (EmpolyPicpictureBox.Image != null)
{
//use to save image
MemoryStream ms = new MemoryStream();
EmpolyPicpictureBox.Image.Save(ms, EmpolyPicpictureBox.Image.RawFormat);
byte[] iemimg = ms.GetBuffer();
ms.Close();
cmd.Parameters.AddWithValue("@Emimage", iemimg);
}
else
{
cmd.Parameters.AddWithValue("@Emimage", EmpolyPicpictureBox.Image = null);
}
推荐答案
使用 DBNull.Value Field(System) [ ^ ]
else
{
cmd.Parameters.AddWithValue("@Emimage", DBNull.Value);
}
这篇关于我们如何在图片框中应用限制。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文