我正在尝试使用 OledbConnection 连接到 SQL Server,但它显示错误
服务器不存在或访问被拒绝
我的代码是
using (OleDbConnection conn = new OleDbConnection(ConnectionString))
{
try
{
// test the connection with an open attempt
conn.Open();
this.Dispose();
}
catch (Exception ex)
{
// inform the user if the connection was not saved
MessageBox.Show(ex.Message, "Connection Test");
}
}