public List <ActiveUser> GetActiveUser() { using (SqlConnection connection = new SqlConnection(connectionString)) { List <ActiveUser> ActiveUserList = new List <ActiveUser>(); SqlCommand command = new SqlCommand(); command.CommandText = "select * from ActiveSession;"; command.Connection = connection; connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ActiveUser Active_User = new ActiveUser(); Active_User.CardNumber = reader["CardNumber"].ToString(); Active_User.PcName = reader["PcName"].ToString(); Active_User.StartingTime = Convert.ToDateTime(reader["StartingTime"]); ActiveUserList.Add(Active_User); } return(ActiveUserList); } }
public List<ActiveUser> GetActiveUser() { using (SqlConnection connection = new SqlConnection(connectionString)) { List<ActiveUser> ActiveUserList = new List<ActiveUser>(); SqlCommand command = new SqlCommand(); command.CommandText = "select * from ActiveSession;"; command.Connection = connection; connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ActiveUser Active_User = new ActiveUser(); Active_User.CardNumber = reader["CardNumber"].ToString(); Active_User.PcName = reader["PcName"].ToString(); Active_User.StartingTime = Convert.ToDateTime(reader["StartingTime"]); ActiveUserList.Add(Active_User); } return ActiveUserList; } }