Hello Everyone,
I got an employee_Works table with columns eid,ename,sdate,edate,wages/day.Now I need to calculate his salary based on sdate and edate. Below are the steps what I followed :
In addition to the other columns i added a boundfiled to gridview manually for salary because it's not a column in this table.I am not sure whether i can do it manually or not.Now I calculated the difference between the dates.
DateTime d1 = DateTime.Parse(sdate);
DateTime d2 = DateTime.Parse(edate);
TimeSpan ds = d2 -d1;DateTime d1 = DateTime.Parse(sdate);
DateTime d2 = DateTime.Parse(edate);
TimeSpan ds = d2 -d1;
float sal = ds * wages;
Now I need to assign this value to the grid view for Salary cell.Let me know how to proceed?
sita kPosted Sep 22, 2013, 2:09 PM
I wrote the below query:
DateTime d1 = DateTime.Parse(sdate);
DateTime d2 = DateTime.Parse(edate);
TimeSpan ds = d2 -d1;DateTime d1 = DateTime.Parse(sdate);
DateTime d2 = DateTime.Parse(edate);
TimeSpan ds = d2 -d1;
select emp_id,emp_name,sdate,edate,wages,wages * ds as SAL from employee_Works;
What is wrong with this query getting an error invalid identifier at ds.
and trying to assign the value ds to the grid view.
grdView.Rows[3].Cells[3].Text = SAL;
Getting an error index out of range. Must be non-negative and less than size of collection.
Regards.