Arg81
Well-known member
Hi All,
Within my database I have a TimeSpent field, which I want to do the following:
(I've managed to do within a DataAdapter by using the following SQL, but when I go to fill the DA's I get an error)
a) SELECT Sum(TimeSpent) AS TimeSpentDWR
FROM DwrWork
WHERE DWRNumber=@DWRNumber
The above totals the time spent in all revisions for a paramaterised DwrNo.
b) SELECT Sum(TimeSpent) AS TimeSpentRevision
FROM DwrWork
WHERE DWRNumber=@DWRNumber and DwrRevision=@DwrRevision
The above totals the time spent for a given revision within a paramaterised DwrNo.
What I couldn't figure out is how to use those DA's within my app so that it looks at the fields DWRNumber and DwrRevision and uses them as the parameters - i.e. so that when the user navigates through the records, the time spent fields are updated respectively.
I then read doing it this way isn't really a good idea because it's looking at the database and not the DataSet. I.E. the fields aren't updated until the user submits the changes made to the DataSet back to the DataBase.....so I thought about using COMPUTE.
Problem I have is that I can't figure out how to word the expression correctly. I think this may be impossible...but when you put the filter in, I want something along the lines of the following:
lblHoursDWR.Text = DsDWR1.DWRWork.Compute("SUM(TimeSpent)", "DWRNumber=lblDwrNo.text")
I get an error with "No Column found by the name of lblDwrNo.text"
I've got it working by manually specifying the DWRNumber, but of course as the users navigate, the label doesn't update.
Any ideas guys? This would be a huge help! I started off as a newbie a few months back, it's amazing what you can learn in such little time!!!
cheers, Luke
Within my database I have a TimeSpent field, which I want to do the following:
(I've managed to do within a DataAdapter by using the following SQL, but when I go to fill the DA's I get an error)
a) SELECT Sum(TimeSpent) AS TimeSpentDWR
FROM DwrWork
WHERE DWRNumber=@DWRNumber
The above totals the time spent in all revisions for a paramaterised DwrNo.
b) SELECT Sum(TimeSpent) AS TimeSpentRevision
FROM DwrWork
WHERE DWRNumber=@DWRNumber and DwrRevision=@DwrRevision
The above totals the time spent for a given revision within a paramaterised DwrNo.
What I couldn't figure out is how to use those DA's within my app so that it looks at the fields DWRNumber and DwrRevision and uses them as the parameters - i.e. so that when the user navigates through the records, the time spent fields are updated respectively.
I then read doing it this way isn't really a good idea because it's looking at the database and not the DataSet. I.E. the fields aren't updated until the user submits the changes made to the DataSet back to the DataBase.....so I thought about using COMPUTE.
Problem I have is that I can't figure out how to word the expression correctly. I think this may be impossible...but when you put the filter in, I want something along the lines of the following:
lblHoursDWR.Text = DsDWR1.DWRWork.Compute("SUM(TimeSpent)", "DWRNumber=lblDwrNo.text")
I get an error with "No Column found by the name of lblDwrNo.text"
I've got it working by manually specifying the DWRNumber, but of course as the users navigate, the label doesn't update.
Any ideas guys? This would be a huge help! I started off as a newbie a few months back, it's amazing what you can learn in such little time!!!
cheers, Luke