把图片保存进数据库了怎么读不出来啊,总是提示参数错误。。 读取:
string com = "select image from ServerList where ServerNumber='P800002'";
SqlConnection con = Link.linkCon();//自定义的
con.Open();
SqlCommand cmd = new SqlCommand(com, con);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
MessageBox.Show(sdr[0].ToString());
byte[] bs = (byte[])sdr[0];
MemoryStream ms = new MemoryStream(bs);
ms.Write(bs, 0, bs.Length);
Image image = Image.FromStream(ms);
// Bitmap bt = new Bitmap(ms);//也行不通
pictureBox1.Image = image;
ms.Close();
con.Close();
数据库imagebyte
------解决方案--------------------
SqlCommand com = new SqlCommand("update ServerList set [image]=@img where ServerNumber='P800002'", conn);
com.Parameters.Add(new SqlParameter("@img", bt));
com.ExecuteNonQuery();