I have a PictureBox control in my Windows Form.
Datatype of Picture column is 'image' in table 'TableName'
These here is the code which says, take the image from database and put it in PictureBox control:
string connectionString = @"Initial Catalog=DataBaseName;Data Source=DataSourceName;Integrated Security=SSPI;";
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlDataAdapter da = new SqlDataAdapter(new SqlCommand("Select Picture From TableName where ID = 2 ", connection));
DataSet ds = new DataSet();
da.Fill(ds);
byte[] myImage = new byte[0];
myImage = (byte[])ds.Tables[0].Rows[0]["Picture"];
MemoryStream stream = new MemoryStream(myImage);
pictureBox1.Image = Image.FromStream(stream);
connection.Close();
Usually it always works but now its showing a ArgumentExeption with error 'Paramerter is not valid' at this line pictureBox1.Image = Image.FromStream(stream);
I don't understand? Which Parameter?
Any help will be appreciated.