static void Main(string[] args)
{
Console.WriteLine(user("k", "1"));
Console.WriteLine(user("天下", "000"));
Console.ReadKey();
}
static bool user(string username, string password)
{
string connectstr = "server=127.0.0.1;port=3306;database=mygame;user=root;password=1234";
MySqlConnection connection = new MySqlConnection(connectstr);
connection.Open();
try
{
string str = "select *from users where username=@kk and password=@pp";
MySqlCommand command = new MySqlCommand(str, connection);
command.Parameters.AddWithValue("kk", username);
command.Parameters.AddWithValue("pp", password);
MySqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
return true;
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
return false;
}
版权声明:本文为weixin_33950757原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。