Skip to content

Latest commit

 

History

History
70 lines (55 loc) · 3.11 KB

sqlwritedsntoini-function.md

File metadata and controls

70 lines (55 loc) · 3.11 KB
titledescriptionauthorms.authorms.datems.servicems.subservicems.topicf1_keywordshelpviewer_keywordsapilocationapinameapitype
SQLWriteDSNToIni Function
SQLWriteDSNToIni Function
David-Engel
davidengel
01/19/2017
sql
connectivity
reference
SQLWriteDSNToIni
SQLWriteDSNToIni [ODBC]
sqlsrv32.dll
SQLWriteDSNToIni
dllExport

SQLWriteDSNToIni Function

Conformance
Version Introduced: ODBC 1.0

Summary
SQLWriteDSNToIni adds a data source to the system information.

Syntax

 BOOL SQLWriteDSNToIni( LPCSTR lpszDSN, LPCSTR lpszDriver); 

Arguments

lpszDSN
[Input] Name of the data source to add.

lpszDriver
[Input] Driver description (usually the name of the associated DBMS) presented to users instead of the physical driver name.

Returns

The function returns TRUE if it is successful, FALSE if it fails.

Diagnostics

When SQLWriteDSNToIni returns FALSE, an associated *pfErrorCode value can 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.

*pfErrorCodeErrorDescription
ODBC_ERROR_GENERAL_ERRGeneral installer errorAn error occurred for which there was no specific installer error.
ODBC_ERROR_INVALID_DSNInvalid DSNThe lpszDSN argument contained a string that was invalid for a DSN.
ODBC_ERROR_INVALID_NAMEInvalid driver or translator nameThe lpszDriver argument was invalid.
ODBC_ERROR_REQUEST_FAILEDRequest failedThe installer failed to create a DSN in the registry.
ODBC_ERROR_OUT_OF_MEMOut of memoryThe installer could not perform the function because of a lack of memory.

Comments

SQLWriteDSNToIni adds the data source to the [ODBC Data Sources] section of the system information. It then creates a specification section for the data source and adds a single keyword (Driver) with the name of the driver DLL as its value. If the data source specification section already exists, SQLWriteDSNToIni removes the old section before creating the new one.

The caller of this function must add any driver-specific keywords and values to the data source specification section of the system information.

If the name of the data source is Default, SQLWriteDSNToIni also creates the default driver specification section in the system information.

This function should be called only from a setup DLL.

Related Functions

For information aboutSee
Adding, modifying, or removing a data sourceConfigDSN(in the Setup DLL)
Adding, modifying, or removing a data sourceSQLConfigDataSource
Removing a data source name from the system informationSQLRemoveDSNFromIni
close