我得到这个错误:的SQL Server 2000/ODBC - 与可信的SQL Server连接
ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
这里是我的代码(C#),我在本地和远程计算机上运行以下命令:
using (OdbcConnection connection = new OdbcConnection("dsn=mydsn"))
{
connection.ConnectionTimeout = 50000;
OdbcCommand command = new OdbcCommand("select * from users", connection);
command.CommandTimeout = 50000;
connection.Open();
OdbcDataReader reader = command.ExecuteReader();
}
DSN细节:
name: mydsn
SQL login: mylogin
database: Test
SQL Server配置:
security: sql server and windows authentication mode
每当我尝试使用登录到Management Studio,一切正常,我可以执行查询。