怎样从数据库中取出image(blob)字段,然后付给image控件? 怎样从数据库中取出image(blob)字段,然后付给image控件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 response.write()其实就是一个定位问题 //把图片读到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; 参考http://dotnet.aspx.cc/ShowDetail.aspx?id=J9UBRVER-L3VB-49M3-GOU1-Z6C2PVR6FZ3K 我用的是webform,可以读出image(blob)但是没办法把它付给image控件 急需解决的问题 我textbox绑定keydown事件,但直接输入也会触发keydown, Tree的样式问题 datagrid获取sqlserver中int型主键的值怎么写? 获取DataList中的触发源控件 谁给个.net开发WAP的教程啊,急 各位大大帮我看下这样做是否可行? 在C#中,如何将%e6%96%87一样的形式的字符串转换成中文字符串 Sql server 关于多实例问题 急求一个委托事件 [高分在线]如何从DataTable中过滤出一个新的DataTable 用c#做asp.net的一个问题!我很菜的。
其实就是一个定位问题
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;
http://dotnet.aspx.cc/ShowDetail.aspx?id=J9UBRVER-L3VB-49M3-GOU1-Z6C2PVR6FZ3K