Microsoft KB Archive/138541

= How to use Odbcping.exe to verify ODBC connectivity to SQL Server =

Article ID: 138541

Article Last Modified on 12/7/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft SQL Server 6.0 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q138541



IN THIS TASK
SUMMARY
 * More Information



SUMMARY
This article describes how to verify ODBC connectivity to SQL Server.

back to the top

More Information
Microsoft SQL Server versions 6.0 and later contain a 32-bit utility named Odbcping.exe that you can use to verify connectivity to SQL Server through ODBC SQL Server drivers. With the Odbcping.exe utility, you verify whether ODBC and the Microsoft SQL Server driver are properly installed by connecting to a server by using the ODBC SQL Server Driver.

Use the following command syntax to use the utility:

odbcping {/S  | /D  } /U   /P

The following parameters are in this command:
 *   is the SQL Server login ID.
 *   is the SQL Server password.
 *   is the network name of the server that is running SQL Server.
 *   the name of an ODBC data source.

You must specify either /  or /  but not both. The version of Odbcping.exe that SQL Server 6.0 includes only accepts the / , / , and /  switches, it does not accept the /  switch. The switches are case sensitive. The 6.0 version of the utility is documented in the ODBC SQL Server Driver help file Drvssrvr.Hlp in the section "Connecting to a Data Source." SQL Server versions 6.0 and 6.5 include this help file. It is also in the SQL Server Books Online Administrator's Companion, Part 6, Chapter 15, "Troubleshooting and Recovery."

You can use the utility against SQL Server versions 4.21a or later, and you can use the Odbcping.exe utility from Microsoft Windows NT- or Microsoft Windows 95-based clients. If you use the /  switch, you can use the utility against any ODBC data source for the Win32 version (or versions) of the Microsoft SQL Server Driver (Sqlsrv32.dll). If you use /  for a data source while you are using a Win32 non-SQL Server driver, Odbcping.exe connects through the data source but it may experience difficulties when it tries to find the SQL Server version string. The utility does not work with Win16 ODBC drivers.

Note This utility has been deprecated in SQL Server 2005.

The following example demonstrates how to use this utility and how to verify the information that it provides.

If you run the following command (where  is the server name)

c:\mssql\binn>odbcping -Sabc -Usa -Pxyz

Odbcping.exe returns the following information on a successful connection (SQL Server and driver version):   CONNECTED TO SQL SERVER ODBC SQL Server Driver Version: 02.65.0201 SQL Server Version: SQL Server for Windows NT 6.50 - 6.50.201 (Intel X86) Apr 3 1996 02:55:53 Copyright (c) 1988-1996 Microsoft Corporation The purpose of the Odbcping.exe utility is to test SQL Server driver data sources. If you use the /  switch to connect to a non-SQL Server driver ODBC data source, Odbcping.exe prints the ODBC driver version, but it does not print correct server information. If errors occur during the connect attempt, Odbcping.exe correctly reports the errors.

For example, if you run the following command on a client that has the ODBC SDK sample applications installed:

c:\mssql\binn>odbcping -Dsdk21-Access32 -Usa -Pxyz

and the connection is successful, the utility generates the following information:   CONNECTED TO SQL SERVER ODBC SQL Server Driver Version: 3.40.2505 SQL Server Version: |^w If you use the /  switch, Odbcping.exe, uses the default network library that you specified in the SQL Client Configuration Utility. If you use the /  switch, Odbcping.exe uses the network library that you defined in the data source. To quickly test the basic setup of multiple network libraries, use the SQL Client Configuration Utility to set different network libraries as the default protocol, and then use Odbcping.exe with the /  switch to test them. For more information about ODBC SQL Server connection parameters, click the following article number to view the article in the Microsoft Knowledge Base:

137635 ODBC SQL Server connection parameters

You can use the utility the same way that you use the ODBC Test utility in the ODBC SDK package: to help load different network libraries and to test the connectivity through ODBC. You can also use it to verify that the ODBC modules are installed and configured correctly. However, you cannot run the utility in a Win16 client environment (for example: Microsoft Windows 3.1, or Microsoft Windows for Workgroups).

NOTE: If you use the 6.0 version of the Odbcping.exe utility to interpret connectivity errors, but you try to connect to a server that does not exist in the network, you do not receive the "pfNative" error so you cannot interpret the actual source of the problem. For more information about how to interpret pfNative code reported by connectivity errors, click the following article number to view the article in the Microsoft Knowledge Base:

137634 Reading ODBC SQL Server driver network messages

Example:

If you use the 6.0 version of the Odbcping.exe utility on an unsuccessful connection with named pipes, you receive the following error message:

C:\utils>odbcping -Sxyz -Usa -P

COULD NOT CONNECT TO SQL SERVER

SQLState: 01000

Error Message: [Microsoft][ODBC SQL Server

Driver][dbnmpntw]

ConnectionOpen (CreateFile).

SQLState: 08001

Error Message: [Microsoft][ODBC SQL Server Driver]

Unable to connect to data source.

However, you receive the following error message if you use the 6.5 version of the Odbcping.exe utility:

C:\utils>odbcping -Sxyz -Usa -P

COULD NOT CONNECT TO SQL SERVER

SQLState: 01000 Native Error: 2

Error Message: [Microsoft][ODBC SQL Server

Driver][dbnmpntw]

ConnectionOpen (CreateFile).

SQLState: 08001 Native Error: 6

Error Message: [Microsoft][ODBC SQL Server

Driver][dbnmpntw]

Specified SQL Server not found.

back to the top

Additional query words: sql6 2.50 odbc windows nt err code

Keywords: kbhowtomaster kbinterop KB138541

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.