我遇到了一些运行的Windows服务问题。我已经创建了一个新的测试服务,它创建了一个带有连接字符串的ODBCConnection,我已经多次验证它是正确的。每当我调用Open()方法时,我都会收到以下错误:
Error: System.Data.Odbc.OdbcException (0x80131937): ERROR [08001] [Simba][SimbaEngine ODBC Driver][DRM File Library]Invalid account name.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.Odbc.OdbcConnection.Open()
我让服务以32位模式运行,DSN是在32位ODBC管理工具中创建的。我能够使用ODBC测试程序连接相同的连接字符串。我也可以通过命令提示符运行该服务,它将完美地工作。我尝试以具有最高权限的用户身份运行服务,但这没有帮助。有没有人对可能造成这种情况有什么想法?
这是正在运行的代码。我删除其他因素是非常基础的:
string connectionString = "verified connection string";
string query = "random query I know works";
OdbcConnection c = new OdbcConnection(connectionString);
try
{
elog.WriteEntry("Opening odbc connection...", EventLogEntryType.Information);
c.Open();
elog.WriteEntry("Opened odbc connection...", EventLogEntryType.Information);
}
catch
{
c.Dispose();
throw;
}