1
Answer

how do get last record from sql

Sajid Hussain

Sajid Hussain

9y
663
1
i have web form and data is inserted properly.against one employee i have multiple records in the table.
 
 EmployeeStatus empStatus = new EmployeeStatus();           
empStatus.Employee_Id = Employee.Id;
empStatus.EmployeeStatusType_Id = SafeConvert.ToByte(ddlEmpStatus.SelectedValue);
empStatus.StartDate = SafeConvert.ToDateTime(txtStartDate.Text);
 empStatus.EndDate = SafeConvert.ToDateTime(txtEndDate.Text);
empStatus.Sector_Id = SafeConvert.ToByte(ddlSelectSector.SelectedValue);
empStatus.Rank_Id = SafeConvert.ToByte(ddlRank.SelectedValue);
empStatus.IsDutiable = txtIsDutiable.Checked;
empStatus.HasWirles = txtHasWirles.Checked;
empStatus.DutyType_Id = SafeConvert.ToByte(ddlDutyType.SelectedValue);
empStatus.EmployeeShift_Id = SafeConvert.ToByte(ddlEmployeeShift.SelectedValue);
 _service.InsertEmployeeStatus(empStatus);
_queryStatus = empStatus.Id > 0;
i have tried all last&default method,orderby,etc but result is getting properly.because against one employee there are different status and different duty type, so i got one idea that i add a new column in that table which is a bit type,and when i insert new record against that employee bit is set true for that last record and for previous records is set false>>how that cab be done using c#.
Answers (1)