title: Image control not being populated by binary data from database
body: <p>I have an image for every student recorded in the database. However when ever l want to show details of a student. All the other stuff is shown besides the image. My code shows no run-time errors or debugging errors. The Id input for the method is the student number entered so as to show information show that student.</p>
  
  <pre><code>private void Image(string id)
  {
      byte[] bytes = (byte[])GetData("SELECT Image FROM SI WHERE  Username=" + id).Rows[0]["Image"];
      string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
      imgPic.ImageUrl = "data:image/jpg;base64," + base64String;
  }
  
  private DataTable GetData(string query)
  {
      DataTable dt = new DataTable();
      string constr = ConfigurationManager.ConnectionStrings["tlcString"].ConnectionString;
  
      using (SqlConnection con = new SqlConnection(constr))
      {
          using (SqlCommand cmd = new SqlCommand(query))
          {
              using (SqlDataAdapter sda = new SqlDataAdapter())
              {
                  cmd.CommandType = CommandType.Text;
                  cmd.Connection = con;
                  sda.SelectCommand = cmd;
                  sda.Fill(dt);
              }
          }
  
          return dt;
      }
  }
  </code></pre>