我与数据库的连接无法正常工作。它尝试加载很长时间然后说连接失败。我要做的就是访问数据库并打印出一个名字。我对此很陌生,但这是我到目前为止所拥有的:
string connectionstring = "uid=user;server=it.et.byu.edu;port=xxxxx;database=database;password=password;";
MySqlConnection connection = new MySqlConnection(connectionstring);
connection.Open();
MySqlCommand cmd = new MySqlCommand("SELECT username FROM Users WHERE username='george'", connection);
try
{
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr.GetString(0));
}
rdr.Close();
}
connection.Close();