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;
MySqlCommand comm = null;
//ПРОВЕРЯЕМ, ЕСТЬ ЛИ УЖЕ ТАКОЙ ЮЗЕР
sql = "UPDATE auth_user SET avatar_path='"+value+"' WHERE name='" + UserName + "';";
comm = new MySqlCommand(sql, conn);
comm.ExecuteNonQuery();
conn.Close();
}
catch (MySqlException exp)
{
conn.Close();
}
}
public static string[] getTeamByUsername(string UserName)
{
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 id = null;
int[] id_team = null;
string[] teams = new string[1];
teams[0] = "";
string sql;
MySqlCommand comm = null;
MySqlDataReader reader = null;
//ВЫБИРАЕМ ID КОМАНДЫ
sql = "SELECT team FROM auth_user WHERE name = '" + UserName + "';";
comm = new MySqlCommand(sql, conn);
reader = comm.ExecuteReader();
while (reader.Read())
{
id = reader[0].ToString();
}
reader.Close();
if (id == null || id == "")
{
conn.Close();
return teams;
}
//БЕРЕМ ИМЯ КОМАНДЫ ПО ID
else
{
id_team = new int[id.Split(',').Length];
for (int i = 0; i < id.Split(',').Length; i++)
{
id_team[i] = Convert.ToInt32(id.Split(',')[i]);
}
teams = new string[id_team.Length];
for (int i = 0; i < id_team.Length; i++)
{
sql = "SELECT name FROM teams WHERE id=" + id_team[i] + ";";
comm = new MySqlCommand(sql, conn);
reader = comm.ExecuteReader();
while (reader.Read())
{
teams[i] = reader[0].ToString();
}
reader.Close();
}
conn.Close();
return teams;
}
}
catch (MySqlException exp)
{
conn.Close();
return null;
}
}
public static string getTeamById(int id)
{
string database = "powerplay";
string password_db = "admin";
string user_db = "root";
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.