将PICTUREBOX中显示的图片(不知道图片路径),存入数据库中:
----------------------------------------------------------
----------------------------------------------------------
1
if
(
null
!=
picBox.Image)
2
{
3
using(System.IO.MemoryStream ms = new System.IO.MemoryStream())
4
{
5
picBox.Image.Save(ms, picBox.Image.RawFormat);
6
Byte[] bt = new Byte[ms.Length];
7
ms.Read(bt, 0, ms.Length);
8
//将bt作为参数,传入 DBCOMMAND即可
9
}
10
}
if
(
null
!=
picBox.Image)2

{3
using(System.IO.MemoryStream ms = new System.IO.MemoryStream())4

{5
picBox.Image.Save(ms, picBox.Image.RawFormat);6
Byte[] bt = new Byte[ms.Length];7
ms.Read(bt, 0, ms.Length);8
//将bt作为参数,传入 DBCOMMAND即可9
} 10
}
博客介绍了将PICTUREBOX中显示的图片(不知图片路径)存入数据库的方法。通过创建内存流,将图片保存到内存流中,再将内存流数据存入字节数组,最后将字节数组作为参数传入DBCOMMAND即可完成操作。
2248

被折叠的 条评论
为什么被折叠?



