I am trying to retrieve an image from my database to appear as the background of my windows form. But the error "There are no rows at position 0" keeps appearing. I have tested it on other forms with the same code and it works fine. May I know what's wrong with the code below?
cmd = new SqlCommand("select Background from Employee where EmployeeName='" + label10.Text + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows[0]["Background"] != System.DBNull.Value)
{
MemoryStream ms = new MemoryStream((Byte[])ds.Tables[0].Rows[0]["Background"]);
this.BackgroundImage = new Bitmap(ms);