Version Introduced: ODBC 1.0
SQLWriteDSNToIni adds a data source to the system information.
[Input] Name of the data source to add.
[Input] Driver description (usually the name of the associated DBMS) presented to users instead of the physical driver name.
The function returns TRUE if it is successful, FALSE if it fails.
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.
General installer error
An error occurred for which there was no specific installer error.
The lpszDSN argument contained a string that was invalid for a DSN.
Invalid driver or translator name
The lpszDriver argument was invalid.
The installer failed to create a DSN in the registry.
Out of memory
The installer could not perform the function because of a lack of memory.
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.