title: How to populate a gridview with database data help?
body: <p>Ok first off do I need to add a data source in the designer? or will the DataSource = reader take care of that, second how can I limit it to the users badge number entered n the source page ie: user enters 3 digit code gets his hours worked typical time sheet format.</p>
  
  <p>Can you guys please help me I'm new to asp c# and databases but I'm trying to learn more each day? oh and can you explain in laymans terms</p>
  
  <pre><code>  string cmdquery = "SELECT * FROM EMPLOYEES WHERE BADGE ='" + Badge + "'";
                  string clquery = " SELECT * FROM CLOCK_HISTORY WHERE BADGE ='" + Badge + "'";
  
  
              OracleCommand cmd = new OracleCommand(cmdquery);
              cmd.Connection = conn;
              cmd.CommandType = CommandType.Text;
              conn.Open();
              using (OracleDataReader reader = cmd.ExecuteReader())
              {
  
                  while (reader.Read())
                  {
                      this.xUserNameLabel.Text += reader["EMPLOYEE_NAME"];
                      this.xDepartmentLabel.Text += reader["REPORT_DEPARTMENT"];
  
                  }
  
  
  
  
              }
  
              conn.Close();
  
  
              OracleCommand clq = new OracleCommand(clquery);
              clq.Connection = conn;
              clq.CommandType = CommandType.Text;
              conn.Open();
  
              using (OracleDataReader reader = clq.ExecuteReader())
              {
  
                      xHoursGridView.DataSource = reader;
                      xHoursGridView.DataBind();
              }
  </code></pre>