我尝试连接到我朋友创建的服务器上的 MySQL 数据库,但它仍然说它无法连接到服务器!
这是我的代码:
String connectionString = "Persist Security Info=False;database=qwertyui;server=www.qwertyuiop.com;Uid=asdfghj;Pwd=qazwsxedc;Connect Timeout=30";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("INSERT INTO etc.... ");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue( etc.... );
connection.Open();
int r = cmd.ExecuteNonQuery();
}
它在connection.Open()
抛出异常的指令上失败 -> 无法连接到服务器。
请问有什么想法吗?