public Character GetCharacterForBuild(int BuildID) { Character requestedCharacter = new Character(); string sql = "SELECT * FROM [Characters] INNER JOIN [BuildsCharacters] ON [Characters].[id] = [BuildsCharacters].[characterID] INNER JOIN [Builds] ON [BuildsCharacters].[buildID] = [Builds].[id] WHERE [Builds].[id] = " + BuildID; cmd.CommandText = sql; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["name"].ToString(); requestedCharacter.ID = id; requestedCharacter.Name = name; } } dr.Close(); conn.Close(); requestedCharacter.Abilities = this.GetAbilitiesForCharacter(requestedCharacter.ID); return requestedCharacter; }
public Character GetCharacter(int CharacterID) { Character requestedCharacter = new Character(); string sql = "SELECT * FROM [Characters] WHERE [id] = " + CharacterID; cmd.CommandText = sql; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["name"].ToString(); int skinCount = Convert.ToInt32(dr["skinCount"]); requestedCharacter.ID = id; requestedCharacter.Name = name; requestedCharacter.SkinCount = skinCount; } } dr.Close(); conn.Close(); return requestedCharacter; }