Hello All - I'm attempting to move an exe over to a windows service. I can bot seem to get ODBC to create a connection. The following code - string connectionString = "DSN=SW Users"; OdbcConnection newConnection = new OdbcConnection(connectionString); newConnection.Open(); throws the following error - ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed n at System.Data.Odbc.OdbcConnection.Open() This exact same code works fine from an exe though. Any info would be appreciated.
Under what logon usernames is the DSN valid? Under what logon username does the service run? - Lee glose wrote: > Hello All - > > I'm attempting to move an exe over to a windows service. I can bot seem > to get ODBC to create a connection. > > The following code - > > string connectionString = "DSN=SW Users"; > OdbcConnection newConnection = new OdbcConnection(connectionString); > newConnection.Open(); > > throws the following error - > > ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's > SQLSetConnectAttr failed > > n > > at System.Data.Odbc.OdbcConnection.Open() > > > > This exact same code works fine from an exe though. > > Any info would be appreciated. >
The DSN is setup as a System DSN and the service is installed as ServiceAccount.LocalSystem.
glose wrote: > The DSN is setup as a System DSN and the service is installed as > ServiceAccount.LocalSystem. LocalSystem account can not access network resources. Is your database local? I typically use a domain user for database work.
There appears to be four choices in the ServiceAccount (Local,System, Network, User) and I've tried all four with no luck. In my test case the DB is local but this won't be the case in production.
glose wrote: > There appears to be four choices in the ServiceAccount (Local,System, > Network, User) and I've tried all four with no luck. > > In my test case the DB is local but this won't be the case in > production. > It has been a very long time since I've done anything with ODBC, but I am beginning to point to the idea that it may be an ODBC specific sort of issue. It is my recollection that for this I would turn on a tracing feature (can't remember where this ways - control panel???) and checked the logs to get the driver specific reason. Maybe if this doesn't help try one of the other groups more specific to ODBC. People who do web work may be a good source also since ASP runs as a service as well.