0

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();
            }
4
  • Are you getting data back at all? If not what is the datatype on "BADGE" in the Oracle database? Is it a char(Somenumber)? Commented Jun 23, 2010 at 16:11
  • well I do get some data the Employee name ad department shows up but what I cant figure out is how to continue getting data from the database and then the next hurdle is to get that data in the grid. Commented Jun 23, 2010 at 16:56
  • Sorry about the delay it was lunchtime Commented Jun 23, 2010 at 16:57
  • As for the data type it is most likely a char(9) Commented Jun 23, 2010 at 17:00

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.