PRB: Service App. Using ODBC Does Not Connect on Windows NT
  
PSS ID Number: Q125768
Article last modified on 02-06-1995
 
2.00.1510
 
WINDOWS
 

-----------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Open Data Base Connectivity, version 2.0
-----------------------------------------------------------------------
 
SYMPTOMS
========
 
An ODBC connection call made from a Windows NT service fails when the
service is started on booting the Windows NT machine. The following message
is received when the SQLConnect or SQLDriverConnect call fails:
 
   SQLState: IM002 - Data source name not found and no default
   driver specified.
 
CAUSE
=====
 
ODBC data source names are always user-specific, so all ODBC applications
(including those running as services) must be run under a Windows NT
account that has a data source defined. For example, if a user logs onto a
Windows NT machine with account L1 and creates data source D1, then D1 will
only be known to applications running under the L1 Windows NT account. If
another user logs onto the same Windows NT machine with a different Windows
NT account, that user's attempt to connect to D1 will not go through. The
above message will be received instead. This is because the Driver Manager
cannot find any data sources that were not defined for the current account.
 
The Windows NT accounts under which Windows NT Services run are controlled
from the Windows NT Control Panel/Services applet. The default is known as
the local system account. Since no user can log onto the local system
account, no ODBC data sources can be defined for this account. Any Windows
NT Services that attempt to connect to ODBC data sources must be run under
a Windows NT account for which the data source has been defined, in the
example above, under account L1.
 
RESOLUTION
==========
 
Use the Control Panel/Services applet to have any Windows NT Service
needing access to an ODBC data source run under a Windows NT login account
for which that data source has been defined.
 
If the service must be run under a specific Windows NT account that has
been given permissions to access resources needed by the service, log into
Windows NT using that account and define the appropriate ODBC data source
for the account.
 
Additional reference words: 2.00.1510 console service 32bit connection MFC
Windows NT
KBCategory: kbusage kberrmsg
KBSubcategory:
 
=============================================================================
 
Copyright Microsoft Corporation 1995.
