public void FillPresentDays()
{
con.Open();
cmd = new OleDbCommand("Select COUNT(*) from AttendanceDatabase WHERE EmpName =@EmpName and Status =@Status and WHERE Date between @d1 and @d2", con);
cmd.Parameters.AddWithValue("@EmpName", txtEmpName.Text);
cmd.Parameters.AddWithValue("@Status", txtP.Text);
cmd.Parameters.AddWithValue("@d1", dtDate1.Value.Date);
cmd.Parameters.AddWithValue("@d2", dtDate2.Value.Date);
cmd.ExecuteNonQuery();
int count = (int)cmd.ExecuteScalar();
txtPdays.Text = count.ToString();
con.Close();
}
非常需要查询帮助
答案 0 :(得分:1)
同样注释extra where子句尝试下面的
cmd = new OleDbCommand("Select COUNT(*) from AttendanceDatabase WHERE EmpName =@EmpName and Status =@Status and Date between @d1 and @d2", con)
答案 1 :(得分:1)
您的查询不正确。 WHERE
子句只能在单个查询中出现一次。
变化:
Select COUNT(*) from AttendanceDatabase WHERE EmpName =@EmpName and Status =@Status and WHERE Date between @d1 and @d2"
为:
Select COUNT(*) from AttendanceDatabase WHERE EmpName =@EmpName and Status =@Status and Date between @d1 and @d2"
答案 2 :(得分:0)
and WHERE
语法不正确。
您只能有一个WHERE
条款。