public List <ScoreItem> GetScoresWithCurrent(string gameName, string gameVariation, Int64 lastScore, SortDirection direction) { List <ScoreItem> scores = new List <ScoreItem>(); try { using (SqlConnection connection = new SqlConnection(@"Data Source=wpcommuter.db.3448251.hostedresource.com; Initial Catalog=wpcommuter; User ID=wpcommuter; Password='******';")) { connection.Open(); SqlCommand command = new SqlCommand("GetScores", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("idScore", lastScore); command.Parameters.AddWithValue("gameName", gameName); command.Parameters.AddWithValue("gameVariation", gameVariation); command.Parameters.AddWithValue("Ascending", (direction == SortDirection.Ascending)); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ScoreItem item = new ScoreItem(); item.Index = Convert.ToInt32(reader["RowNumber"]); item.User = Convert.ToString(reader["User"]); item.Score = (float)(double)reader["Score"]; item.IsLast = Convert.ToBoolean(reader["MyScore"]); item.Date = (DateTime)reader["Date"]; scores.Add(item); } } } } catch { } return(scores); }
public List<ScoreItem> GetScoresWithCurrent(string gameName, string gameVariation, Int64 lastScore, SortDirection direction) { List<ScoreItem> scores = new List<ScoreItem>(); try { using (SqlConnection connection = new SqlConnection(@"Data Source=wpcommuter.db.3448251.hostedresource.com; Initial Catalog=wpcommuter; User ID=wpcommuter; Password='******';")) { connection.Open(); SqlCommand command = new SqlCommand("GetScores", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("idScore", lastScore); command.Parameters.AddWithValue("gameName", gameName); command.Parameters.AddWithValue("gameVariation", gameVariation); command.Parameters.AddWithValue("Ascending", (direction == SortDirection.Ascending)); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ScoreItem item = new ScoreItem(); item.Index = Convert.ToInt32(reader["RowNumber"]); item.User = Convert.ToString(reader["User"]); item.Score = (float)(double)reader["Score"]; item.IsLast = Convert.ToBoolean(reader["MyScore"]); item.Date = (DateTime)reader["Date"]; scores.Add(item); } } } } catch { } return scores; }