1.You do not need to use
SqldataAdapter
for reading image from database, you should use
SqlCommand
instead like in the next example:
IDataReader reader = null;
byte[] imageData = null;
try
{
IDbCommand dbCommand = new SqlCommand();
dbCommand.Connection = con;
dbCommand.CommandText = string.Format("select photo from tbl_image where id=1);
//
reader = dbCommand.ExecuteReader();
//
if (reader.Read())
{
imageData = (byte[])reader["photo"];
}
}
finally
{
if (reader != null)
reader.Close();
//
con.Close();
}
2.Then you should use this data similar like you did:
if(imageData != null)
{
MemoryStream ms = new MemoryStream(imageData);
pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}