Safiron

DataMapper

Dec 8th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1.         // VRÁTÍ SEZNAM VŠECH HRÁČŮ HRAJÍCÍCH V DANÉM ZÁPASE
  2.         public List<Models.Player> getPlayersByMatch(string matchID)
  3.         {
  4.             List<Models.Player> tempList = new List<Models.Player>();
  5.  
  6.             SqlDataReader myReader = null;
  7.  
  8.             string commandText = "SELECT playerID, teamID, fname, lname FROM Player JOIN [Player-Match] ON Player.playerID = [Player-Match].Player_playerID WHERE Match_matchID = @matchID";
  9.             using (SqlConnection conn = base.NewConnection())
  10.             {
  11.                 conn.Open();
  12.                 myCommand = new SqlCommand(commandText, conn);
  13.                 myCommand.Parameters.AddWithValue("@matchID", matchID);
  14.                 myReader = myCommand.ExecuteReader();
  15.                 while (myReader.Read())
  16.                 {
  17.                     tempList.Add(new Models.Player(myReader[0].ToString(), myReader[1].ToString(), myReader[2].ToString(), myReader[3].ToString(), null, null, null, null, null, null, null, null));
  18.                 }
  19.                 myReader.Close();
  20.                 conn.Close();
  21.                 return tempList;
  22.             }
  23.            
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment