日期:2014-05-18 浏览次数:20981 次
using (SqlConnection con = new SqlConnection(connect.conn))
{
FileStream fs = new FileStream(connect.picpath,FileMode.Open,FileAccess.Read);
byte[] imagebytes = new byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));
con.Open();
SqlCommand com = new SqlCommand("insert into employees(photo) values(@image) where employeeID="+this.textBox6.Text,con);
SqlParameter image = new SqlParameter("@image",SqlDbType.Image);
image.Value = imagebytes;
com.Parameters.Add(image);
com.ExecuteNonQuery();
}