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

时间:2023-01-15 19:16:44

This is my code; I try to retrieve image. I try to resolve but fail:

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

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 个解决方案

#1


parameter is not valid is only show.while image save on db without given perimeter and no error is generate the error is occurring while retrieve from DB

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

#1


parameter is not valid is only show.while image save on db without given perimeter and no error is generate the error is occurring while retrieve from DB

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