C# gGetAllEmployees()@RamishaFarrukh可能您试图将GetAllEmployees()的结果赋给不是System.Collection.Generic.List类型的变量,这就是错误发生的原因。请在调用GetAllEmployee
C# gGetAllEmployees()@RamishaFarrukh可能您试图将GetAllEmployees()的结果赋给不是System.Collection.Generic.List类型的变量,这就是错误发生的原因。请在调用GetAllEmployee,c#,C#,gGetAllEmployees()@RamishaFarrukh可能您试图将GetAllEmployees()的结果赋给不是System.Collection.Generic.List类型的变量,这就是错误发生的原因。请在调用GetAllEmployees()@RamishaFarrukh的地方共享您的代码。如果我看不到导致错误的代码,我将无能为力。 public class Employees { public String emp_id { get;
g
GetAllEmployees()
@RamishaFarrukh可能您试图将GetAllEmployees()
的结果赋给不是System.Collection.Generic.List
类型的变量,这就是错误发生的原因。请在调用GetAllEmployees()
@RamishaFarrukh的地方共享您的代码。如果我看不到导致错误的代码,我将无能为力。
public class Employees
{
public String emp_id { get; set; }
public String emp_name { get; set; }
public String u_name { get; set; }
public String pass { get; set; }
public String mail { get; set; }
public String address { get; set; }
public String city { get; set; }
public String dob { get; set; }
public String cnic { get; set; }
public String designation { get; set; }
public String ph_no { get; set; }
}
public class @object
{
public static List<Employees> GetAllEmployees()
{
List<Employee> listemp = new List<Employee>();
string cs = ConfigurationManager.ConnectionStrings[@"Data Source = localhost; Initial Catalog=fms; User=root; Pooling=false; Integrated Security = false"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(cs))
{
MySqlCommand cmd = new MySqlCommand("Select * from emp", con);
con.Open();
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Employees em = new Employees();
em.emp_id = dr[0].ToString();
em.emp_name = dr[1].ToString();
em.u_name = dr[2].ToString();
em.pass = dr[3].ToString();
em.mail = dr[4].ToString();
em.address = dr[5].ToString();
em.city = dr[6].ToString();
em.dob = dr[7].ToString();
em.cnic = dr[8].ToString();
em.designation = dr[9].ToString();
em.ph_no = dr[10].ToString();
}
listemp.Add(em);
}
}
}
public static List<Employees> GetAllEmployees()
{
List<Employee> listemp = new List<Employee>();
string cs = ConfigurationManager.ConnectionStrings[@"Data Source = localhost; Initial Catalog=fms; User=root; Pooling=false; Integrated Security = false"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(cs))
{
MySqlCommand cmd = new MySqlCommand("Select * from emp", con);
con.Open();
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Employees em = new Employees();
em.emp_id = dr[0].ToString();
em.emp_name = dr[1].ToString();
em.u_name = dr[2].ToString();
em.pass = dr[3].ToString();
em.mail = dr[4].ToString();
em.address = dr[5].ToString();
em.city = dr[6].ToString();
em.dob = dr[7].ToString();
em.cnic = dr[8].ToString();
em.designation = dr[9].ToString();
em.ph_no = dr[10].ToString();
listemp.Add(em);
}
}
return listemp;
}
public static List<Employees> GetAllEmployees()
{
List<Employee> listemp = new List<Employee>();
string cs = ConfigurationManager.ConnectionStrings[@"Data Source = localhost; Initial Catalog=fms; User=root; Pooling=false; Integrated Security = false"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(cs))
{
MySqlCommand cmd = new MySqlCommand("Select * from emp", con);
con.Open();
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Employees em = new Employees();
em.emp_id = dr[0].ToString();
em.emp_name = dr[1].ToString();
em.u_name = dr[2].ToString();
em.pass = dr[3].ToString();
em.mail = dr[4].ToString();
em.address = dr[5].ToString();
em.city = dr[6].ToString();
em.dob = dr[7].ToString();
em.cnic = dr[8].ToString();
em.designation = dr[9].ToString();
em.ph_no = dr[10].ToString();
listemp.Add(em);
}
}
return listemp;
}
return listemp