How to update a value by using the result of select query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GEETHA LAKSHMI

    How to update a value by using the result of select query

    I want to use where conditions in both update and select query
    Code:
    cmd1.CommandText = "Update AttRegister set Present= (Select count(Working) from Attendance where Attendance.Working='P' and Attendance.EmpCode=" & row!Empcode & " and Attendance.AttDate between #" & Convert.ToDateTime(CmbFromDate.Text.Substring(6, 4) + "/" + CmbFromDate.Text.Substring(3, 2) + "/" + CmbFromDate.Text.Substring(0, 2)) & "# and #" & Convert.ToDateTime(CmbToDate.Text.Substring(6, 4) + "/" + CmbToDate.Text.Substring(3, 2) + "/" + CmbToDate.Text.Substring(0, 2)) & "#) where AttRegister.EmpCode=" & row!EmpCode
    cmd1.ExecuteNonQuery()
Working...