Hi
I am getting above error . Data file also attached.
public List<Employee> GetAllEmployee() { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["cnn0"].ConnectionString); string query = "select empid,firstname,lastname,dept,sex from Oh "; SqlCommand cmd = new SqlCommand(query, conn); List<Employee> Employee = new List<Employee>(); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { Employee.Add(new Employee { EmpId = (int)dr[0], FirstName = dr[1].ToString(), LastName = dr[2].ToString(), Dept = (int)dr[3], Sex = dr[4].ToString() }); } } conn.Close(); return Employee; }
Thanks
Attachment: Data.rar