我已连接到远程主机上的数据库。
这是引发异常的代码:
private async void Form1_Load(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["Drugs"].ConnectionString;
sqlConnection = new SqlConnection(connectionString);
await sqlConnection.OpenAsync(); // throws System.Threading.Tasks.TaskCanceledException
}
这是我的app.config文件:
<connectionStrings>
<add name="Drugs"
providerName="System.Data.SqlClient"
connectionString="Data Source=<ip address>;Initial Catalog=<database>;User Id=<my username>;Password=<my password>" />
</connectionStrings>
如何诊断和解决此问题?