title: Error cannot find Column 2 dr = ds.Tables[0].Rows[0]
body: <p>I've been searching for an answer since this code was working fine like an hour ago and I did not make any editting so it turns a little confuse to recognize the error if any of you could help I would appreciate it much. Thanks in advance.</p>
  
  <p>I've checked and there are no errors on the SQL query, as I said it was working fine dr is defined globally as:
  DataRow dr = new DataRow();
  and MyTable is defined globally also as</p>
  
  <pre><code>DataTable MyTable = new DataTable();
  </code></pre>
  
  <p>here's the related code:</p>
  
  <pre><code>sentencia = "select * from Facturas" + Session["sociotabla"].ToString() + " where IdFactura = " + Session["idFactura"].ToString();
  ds = bd.Consulta(sentencia);
  if (ds != null)
  {
      dr = MyTable.NewRow();
      dr = ds.Tables[0].Rows[0];
      LimpiarControles();
      tbFactura.Text = dr[0].ToString();
      ListItem li;
      for (int i = 0; i &lt; ddlCliente.Items.Count; i++)
      {
          li = ddlCliente.Items[i];
          if (li.Value == dr[2].ToString()) //Error here Cannot find Column 2
          {
              ddlCliente.SelectedIndex = i;
              Session["idCliente"] = dr[2].ToString();
              break;
          }
      }
  </code></pre>