I'm trying to load some image data stored on SQL server from .Net but while starting an error appearances on screen with a message : Failed to convert parameter value from a DataRowView to a Int32 But I don't know where is the problem.
Code of this part:
try
{
conn.Open();
strSQL = "SELECT * FROM Pictures WHERE ID = @ID";
da = new SqlDataAdapter(strSQL, conn);
da.SelectCommand.Parameters.Add("@ID" ,SqlDbType.Int).Value = listBox1.SelectedValue;
ds = new DataSet();
da.Fill(ds, "Pictures");
byte[] arrPic = (byte[])(ds.Tables["Pictures"].Rows[0]["Pic"]);
MemoryStream ms = new MemoryStream(arrPic);
pictureBox1.Image = Image.FromStream(ms);
conn.Close();
}
catch (SystemException ex)
{
MessageBox.Show(ex.Message);
}
Error is on "da.Fill(ds, "Pictures");"