1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| private static SqlConnection conn = new SqlConnection("Data Source=..\\..; " +
"Initial Catalog=..;Integrated Security=True");
private static SqlConnection conn2 = new SqlConnection("Data Source=..\\..; " +
"Initial Catalog=..;Integrated Security=True");
#endregion
#region Methods
#region FetchAllUsers Method
public static List<UserBO> FetchAllUsers ()
{
List<UserBO> lstUsers = new List<UserBO>();
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT DISTINCT FIRSTNAME, LASTNAME FROM USERS", conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
lstUsers .Add(
new UserBO()
{
Nom= reader ["FIRSTNAME"].ToString(),
Prenom= reader ["LASTNAME"].ToString()
}
);
}
reader.Close();
conn.Close();
return lstUsers ;
}
catch (Exception e)
{
throw e;
}
}
#endregion |
Partager