SQLRemoveTranslator

Conformance

Version Introduced: ODBC 3.0

Summary

SQLRemoveTranslator removes information about a translator from the ODBCINST.INI section of the system information and decrements the translator’s component usage count by 1.

Syntax

BOOL SQLRemoveTranslator (
   LPCSTR   lpszTranslator,
   LPDWORD   lpdwUsageCount);

Arguments

lpszTranslator

[Input]
The name of the translator as registered in the ODBCINST.INI key of the system information.

lpdwUsageCount

[Output]
The usage count of the translator after this function has been called.

Returns

The function returns TRUE if it is successful, FALSE if it fails. If no entry exists in the system information when this function is called, the function returns FALSE.

Diagnostics

When SQLRemoveTranslator returns FALSE, an associated *pfErrorCode value may be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.

*pfErrorCode Error Description
ODBC_ERROR_
GENERAL_ERR
General installer error An error occurred for which there was no specific installer error.
ODBC_ERROR_
COMPONENT_
NOT_FOUND
Component not found in registry The installer could not remove the translator information because it either did not exist in the registry or could not be found in the registry.
ODBC_ERROR_
INVALID_NAME
Invalid driver or translator name The lpszTranslator argument was invalid.
ODBC_ERROR_
USAGE_
UPDATE_
FAILED
Could not increment or decrement the component usage count The installer failed to decrement the usage count of the driver.
ODBC_ERROR_
OUT_OF_MEM
Out of memory The installer could not perform the function because of a lack of memory.

Comments

SQLRemoveTranslator complements the SQLInstallTranslatorEx function, and updates the component usage count in the system information. This function should only be called from a setup application.

SQLRemoveTranslator will decrement the component usage count by 1. If the component usage count goes to 0, then the translator entry in the system information will be removed. The translator entry is in the following location in the system information, under the translator name:

HKEY_LOCAL_MACHINE
   SOFTWARE
      ODBC
         ODBCINST.INI

SQLRemoveTranslator does not actually remove any files. The calling program is responsible for deleting files, and maintaining the file usage count. Only after both the component usage count and the file usage count have reached zero is a file physically deleted. Some files in a component can be deleted, and others not deleted, depending upon whether the files are used by other applications that have incremented the file usage count.

SQLRemoveTranslator is also called as part of an upgrade process. If an application detects that it has to perform an upgrade, and it has previously installed the driver, then the driver should be removed, then reinstalled. SQLRemoveTranslator should first be called to decrement the component usage count, then SQLInstallTranslatorEx should then be called to increment the component usage count. The application setup program must physically replace the old files with the new files. The file usage count will remain the same, and other applications that use the older version files will now use the newer version.

Related Functions

For information about See
Installing a translator SQLInstallTranslatorEx