tags:

views:

42

answers:

1

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.

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

  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();
            }
+1  A: 

You don't need a DataSource control in the markup if you're setting the DataSource property of your Gridview e.g. DataSource = reader - these are (essentially) two different ways to achieve the same result. Using a DataSource control allows you to connect the controls on your page to a database (databinding), without writing any code - there's a useful article on using them here.

PhilPursglove