none
Unable to open ODBC connection from Windows Service in .Net RRS feed

  • Question

  • Hi All,

    I worte a simple windows application to connect to a third party database (pervasive / timberline) through ODBC. It is working fine but when I moved the same code to a windows service, it is unable to open the connection. I get the following error.

    System.Data.Odbc.OdbcException
       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, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.Odbc.OdbcConnection.Open()

    I installed it as a network service. The Data files for the database is kept as a shared location on the same machine and the folder has the permission for access by Network Services Account.

    I checked the eventlog and found a couple of entries whenever there is a crash. I have listed below

    1. Faulting application MyService.exe, version 1.0.0.0, faulting module tsSimba.dll, version 9.6.25.10, fault address 0x0001f74c.

    2. The system has called a custom component and that component has failed and generated an exception. This indicates a problem with the custom component. Notify the developer of this component that a failure has occurred and provide them with the information below.
    Component Prog ID: 0[ODBC][Env 33012a0]
    Method Name: IDispenserDriver::CreateResource
    Process Name: MyService.exe
    Exception: C0000005
    Address: 0x628AF74C
    Call Stack:
    tssimba!x_dll_version + 0x1D31F
    tssimba!x_dll_version + 0x1DFF3
    tssimba!x_dll_version + 0x514B
    tssimba!rcCnvConvert + 0x44D


    I have tried installing the service as Local System, Local Service, User. But I kept getting the same error.

    Please help.

    Thanks in Advance.


    Monday, November 16, 2009 2:51 PM

Answers

  • Try running it under your interractive login ID (the one you log on to the machine with). If that works then I would suspect it's a permissions issue.
    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Yichun_Feng Monday, November 23, 2009 2:13 AM
    Tuesday, November 17, 2009 1:06 PM

All replies

  • You posted the exception stack, but what is the actual exception error message?
    Val Mazur (MVP) http://www.xporttools.net
    Tuesday, November 17, 2009 11:32 AM
    Moderator
  • Try running it under your interractive login ID (the one you log on to the machine with). If that works then I would suspect it's a permissions issue.
    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Yichun_Feng Monday, November 23, 2009 2:13 AM
    Tuesday, November 17, 2009 1:06 PM
  • I have a similar problem, have you found the solution?

    Tuesday, November 24, 2009 10:40 PM
  • I don't know if it is the same as the error I was getting:

    ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    To correct that error, I moved the ODBC DSN from "User DSN" to "System DSN" in the Data Sources (ODBC), since the user NETWORK SERVICE, which was running my service, could not connect to my user's DSN.
    Tuesday, January 26, 2010 9:20 PM