从图像数据类型DB检索图像时参数无效

时间:2015-05-13 05:16:23

标签: c# image visual-studio-2010

这是我的代码;我尝试检索图像。我试着解决但失败了:

SqlCommand cmd = new SqlCommand("select pic from pic where idimg= '" + listBox1.Text + "'", con);
SqlDataReader r;

con.Open();
r = cmd.ExecuteReader();

while (r.Read())
{
    byte[] storedImage = (byte[])(r["pic"]);
    MemoryStream ms = new MemoryStream(storedImage);
    pictureBox1.Image = Image.FromStream(ms); // Error :Parameter is not valid
}

r.Close();
con.Close();

1 个答案:

答案 0 :(得分:0)

参数无效只是show.while图像保存在没有给定边界的数据库上且没有错误生成从DB检索时发生错误