c#存图到数据库 如何把一张图片存到SQLSERVER数据库中,字段类型为IMAGE;然后再将信息显示到pictureBox中. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 顶朋友 看看这个问题。http://community.csdn.net/Expert/topic/5686/5686047.xml?temp=.8212702 //把图片读到pictureBox,再写入数据库SqlConnection conn=new SqlConnection(@"data source=chenyuming2004\VSdotNET;uid=sa;pwd=cym;database=lhf");conn.Open();SqlCommand cmd=new SqlCommand("insert into fuser values ('1a','1b',@i)",conn);byte[] ib=new Byte[60000];FileStream fs=new FileStream(@"D:\windows temp\temp\1.jpg",FileMode.Open ,FileAccess.Read );fs.Read(ib,0,60000);cmd.Parameters.Add("@i",SqlDbType.Image,(int)fs.Length);cmd.Parameters["@i"].Value=ib;cmd.ExecuteNonQuery();conn.Close();-------------------------------------------------------//从数据库读图片到pictureboxSqlConnection conn=new SqlConnection(@"data source=chenyuming2004\VSdotNET;uid=sa;pwd=cym;database=lhf");conn.Open();SqlCommand cmd=new SqlCommand("select 照片 from fuser where password='1b'",conn);SqlDataReader reader=cmd.ExecuteReader();reader.Read();MemoryStream buf=new MemoryStream((byte[])reader[0]);Image image=Image.FromStream(buf,true);pictureBox1.Image=image; 先将图片转化为二进制流数组,再存入数据库,然后从数据库中读出二进制来,就可以在picturebox 上显示了 关于NHibernate? c# winfrom 托盘显示 求教一个很菜的问题 如何获得来电号码? C# 一些语音识别的问题 WinFrom 树控件 展开节点 partial class的问题 接着提问,1小时内结贴 在Studio 2008里实现统计SQL表里数据,用饼形图显示出来,关于画饼图的代码 谁有c#的反编译软件.谁知道在哪里下载 C# 怎么判断本机是否安装了IIS .net开发的CS程序,在win 2000 win XP上都运行正常,在win 2003下 班出现如下错无
朋友 看看这个问题。http://community.csdn.net/Expert/topic/5686/5686047.xml?temp=.8212702
conn.Open();
SqlCommand cmd=new SqlCommand("insert into fuser values ('1a','1b',@i)",conn);
byte[] ib=new Byte[60000];
FileStream fs=new FileStream(@"D:\windows temp\temp\1.jpg",FileMode.Open ,FileAccess.Read );
fs.Read(ib,0,60000);
cmd.Parameters.Add("@i",SqlDbType.Image,(int)fs.Length);
cmd.Parameters["@i"].Value=ib;
cmd.ExecuteNonQuery();
conn.Close();-------------------------------------------------------
//从数据库读图片到pictureboxSqlConnection conn=new SqlConnection(@"data source=chenyuming2004\VSdotNET;uid=sa;pwd=cym;database=lhf");
conn.Open();
SqlCommand cmd=new SqlCommand("select 照片 from fuser where password='1b'",conn);
SqlDataReader reader=cmd.ExecuteReader();
reader.Read();
MemoryStream buf=new MemoryStream((byte[])reader[0]);
Image image=Image.FromStream(buf,true);
pictureBox1.Image=image;