Создание веб-приложения, сочетающего в себе проектирование и создание баз данных, работу со сторонними форматами данных, программирование в NET и веб-разработку, страница 87

                }

                else

                {

                    conn.Close();

                    return;

                }

                dt.Clear();

                da = new MySqlDataAdapter(sql, conn);

                da.Fill(dt);

                report.DataSource = dt;

                report.DataBind();

                conn.Close();

            }

            catch (MySqlException exp)

            {

                conn.Close();

            }

        }

        public static void getTeamByNameOfTeam(string team, GridView report)

        {

            string database = "powerplay";

            string password_db = "admin";

            string user_db = "root";

            string server_db = "localhost";

            connectionString = ("server=" + server_db + "; user id=" + user_db + "; password=" + password_db + "; database=" + database + "");

            MySqlConnection conn = null;

            try

            {

                //ОБЪЯВЛЕНИЕ

                conn = new MySqlConnection(connectionString);

                conn.Open();

                string sql;

                MySqlDataAdapter da = null;

                DataTable dt = new DataTable();

                //ВЫБИРАЕМ ID КОМАНДЫ

                sql = "SELECT * FROM teams WHERE name = '" + team + "';";

                dt.Clear();

                da = new MySqlDataAdapter(sql, conn);

                da.Fill(dt);

                report.DataSource = dt;

                report.DataBind();

                conn.Close();

            }

            catch (MySqlException exp)

            {

                conn.Close();

            }

        }

        //public static string getTeamForPlayer(string player)

        //{

        //    string database = "powerplay";

        //    string password_db = "admin";

        //    string user_db = "root";

        //    string server_db = "localhost";

        //    connectionString = ("server=" + server_db + "; user id=" + user_db + "; password=" + password_db + "; database=" + database + "");

        //    MySqlConnection conn = null;

        //    try

        //    {

        //        //ОБЪЯВЛЕНИЕ

        //        conn = new MySqlConnection(connectionString);

        //        conn.Open();

        //        int id_team = 0;

        //        string team = "";

        //        string sql;

        //        MySqlCommand comm = null;

        //        MySqlDataReader reader = null;

        //        //ВЫБИРАЕМ ID КОМАНДЫ

        //        sql = "SELECT team FROM players WHERE name = '" + player + "';";

        //        comm = new MySqlCommand(sql, conn);

        //        reader = comm.ExecuteReader();

        //        while (reader.Read())

        //        {

        //            id_team = Convert.ToInt32(reader[0].ToString());

        //        }

        //        reader.Close();

        //        if (id_team == 0)

        //        {

        //            conn.Close();

        //            return null;

        //        }

        //        //БЕРЕМ ИМЯ КОМАНДЫ ПО ID

        //        else

        //        {

        //            sql = "SELECT name FROM teams WHERE id=" + id_team + ";";

        //            comm = new MySqlCommand(sql, conn);

        //            reader = comm.ExecuteReader();

        //            while (reader.Read())

        //            {

        //                team = reader[0].ToString();

        //            }

        //            reader.Close();

        //            conn.Close();

        //            return team;

        //        }

        //    }