By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

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

P: n/a
I want to use where conditions in both update and select query
Expand|Select|Wrap|Line Numbers
  1. 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
  2. cmd1.ExecuteNonQuery()
  3.  
Nov 2 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.