title: 'Object' does not contain a definition for 'Rows' and no extension method 'Rows' accepting a first argument of type 'object' could be found
body: <blockquote>
    <p>'Object' does not contain a definition for 'Rows' and no extension
    method 'Rows' accepting a first argument of type 'object' could be
    found are you missing a using directive or an assembly reference?</p>
  </blockquote>
  
  <p>The code is given below:</p>
  
  <pre><code>public partial class Default3 : System.Web.UI.Page
  {
      static SqlConnection con = new SqlConnection(@"connectionString");
      protected void Page_Load(object sender, EventArgs e)
      {
      if (!this.IsPostBack)
          {
              ddlImg.DataSource = GetData("SELECT EmpID, EmpName FROM Tbl_Emp");
              ddlImg.DataTextField = "EmpName";
              ddlImg.DataValueField = "EmpID";
              ddlImg.DataBind();
          }
  
      }
  
      private object GetData(string query)
      {
          DataTable dt = new DataTable();
          string constr = ConfigurationManager.ConnectionStrings["tbFiles2ConnectionString"].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;
          }
      }
  
      protected void Button1_Click(object sender, EventArgs e)
      {
          SqlCommand cmd = new SqlCommand();
          con.Open();
          cmd.Connection = con;
          cmd.CommandText = ("INSERT INTO Tbl_Emp(EmpID, EmpName, EmpPic ) VALUES('"+TextBox1.Text+"','"+TextBox2.Text+"','" + FileUpload1 + "')");
          cmd.ExecuteNonQuery();
          con.Close();
      }
      protected void Button2_Click(object sender, EventArgs e)
      {
          string id = ddlImg.SelectedItem.Value;
          Image1.Visible = id != "0";
          if (id != "0")
          {
              byte[] bytes = (byte[])GetData("SELECT Data FROM Tbl_Emp WHERE Emp_ID =" + id).Rows[0]["Data"]; // Error popup here
              string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
              Image1.ImageUrl = "data:image/png;base64," + base64String;
          }
      }
  }
  </code></pre>