JC Ballo

JC Ballo

  • 1.3k
  • 53
  • 1.6k

c# date range from/to

Apr 3 2023 6:49 AM

Hello guys please help me, I'm creating a time keeping I want the daterange from/to into textbox here is my code:

using (SqlConnection sqlConnection = new SqlConnection(Connect.pcnTEIPI))
            {

                SqlCommand command = new SqlCommand("select * from [AttendanceView] where Fullname ='" + cboName.Text + "' and TimeIn >= '"+ dtpDateFrom.Text +"' and TimeOut <= '"+ dtpDateto.Text +"'", sqlConnection);
                sqlConnection.Open();

                SqlDataReader read = command.ExecuteReader();

                while (read.Read())
                {
                    txtEmpNumber.Text = (read["Employeenumber"].ToString());
                    txtLastname.Text = (read["Lastname"].ToString());
                    txtFirstname.Text = (read["Firstname"].ToString());
                    txtType.Text = (read["Type"].ToString());
                    txtDepartment.Text = (read["Department"].ToString());
                    txtPosition.Text = (read["Position"].ToString());
                    TimeIN1.Text = (read["TimeIn"].ToString());
                    TimeOUT1.Text = (read["TimeOut"].ToString());
                    TimeIN2.Text = (read["TimeIn"].ToString());
                    TimeOUT2.Text = (read["TimeOut"].ToString());
                }
            }


Answers (9)