存取图片(C#+Winform+SQL Server)
01月 24th, 2005 by Genthelvite
将picture中的图片保存到数据库中,以及从数据库中的图片读取到picture中!
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();
Frederick G. (Rick) Bridging Says
Very good informations and give me good few ideas how I can improve my online tool. Why is it twice as easy to train Iraqi fighter pilots? You only have to teach them to take off
Mar 5th, 2010 at 8:32 pm