日期:2014-05-16 浏览次数:20976 次
FileStream fs = new FileStream(txt_图片路径.Text, FileMode.Open);
byte[] imagebytes = new byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));
fs.Close();
//打开数据库
SqlConnection con = new SqlConnection("server=(local);uid=sa;pwd=xxxxx;database=减速机内容管理系统");
con.Open();
SqlCommand com = new SqlCommand("insert into 图片列表 values(@ImageList,'','')Select @@identity", con);
com.Parameters.Add("ImageList", SqlDbType.Image);
com.Parameters["ImageList"].Value = imagebytes;
int Gid = Convert.ToInt32(com.ExecuteScalar());
con.Close();
lab_图片存入提示.Text = "存入提示:储存成功,ID:" + Gid;
//装配型式
FileStream fs装配型式 = new FileStream(txt_装配型式图片路径.Text, FileMode.Open);
byte[] imagebytes装配型式 = new byte[fs装配型式.Length];
BinaryReader br装配型式 = new BinaryReader(fs装配型式);
imagebytes装配型式 = br装配型式.ReadBytes(Convert.ToInt32(fs装配型式.Length));
fs装配型式.Close();
//选型标记
FileStream fs选型标记 = new FileStream(txt_选型标记图片路径.Text, FileMode.Open);
byte[] imagebytes选型标记 = new byte[fs选型标记.Length];
BinaryReader br选型标记 = new BinaryRead