SQLWriteDSNToIni 函数SQLWriteDSNToIni Function

Conformance
引入的版本: ODBC 1。0Version Introduced: ODBC 1.0

摘要Summary
SQLWriteDSNToIni 将数据源添加到系统信息。SQLWriteDSNToIni adds a data source to the system information.

语法Syntax

  
BOOL SQLWriteDSNToIni(  
     LPCSTR   lpszDSN,  
     LPCSTR   lpszDriver);  

参数Arguments

lpszDSNlpszDSN
送要添加的数据源的名称。[Input] Name of the data source to add.

lpszDriverlpszDriver
送驱动程序描述 (通常会呈现给用户的关联 DBMS) 名称,而不是物理驱动程序名称。[Input] Driver description (usually the name of the associated DBMS) presented to users instead of the physical driver name.

返回Returns

如果此函数成功,则返回 TRUE,否则返回 FALSE。The function returns TRUE if it is successful, FALSE if it fails.

诊断Diagnostics

SQLWriteDSNToIni 返回 FALSE 时,可以通过调用 SQLInstallerError 获取关联的 * pfErrorCode 值。When SQLWriteDSNToIni returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. 下表列出了可由 SQLInstallerError 返回的 * pfErrorCode 值,并说明了此函数的上下文中的每个值。The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.

*pfErrorCode*pfErrorCode 错误Error 说明Description
ODBC_ERROR_GENERAL_ERRODBC_ERROR_GENERAL_ERR 常规安装程序错误General installer error 出现错误,但没有特定的安装程序错误。An error occurred for which there was no specific installer error.
ODBC_ERROR_INVALID_DSNODBC_ERROR_INVALID_DSN DSN 无效Invalid DSN LpszDSN 参数包含对于 DSN 无效的字符串。The lpszDSN argument contained a string that was invalid for a DSN.
ODBC_ERROR_INVALID_NAMEODBC_ERROR_INVALID_NAME 无效的驱动程序或转换器名称Invalid driver or translator name LpszDriver 参数无效。The lpszDriver argument was invalid.
ODBC_ERROR_REQUEST_FAILEDODBC_ERROR_REQUEST_FAILED 申请失败。Request failed 安装程序无法在注册表中创建 DSN。The installer failed to create a DSN in the registry.
ODBC_ERROR_OUT_OF_MEMODBC_ERROR_OUT_OF_MEM 内存不足Out of memory 由于内存不足,安装程序无法执行此功能。The installer could not perform the function because of a lack of memory.

注释Comments

SQLWriteDSNToIni 将数据源添加到系统信息的 [ODBC 数据源] 部分。SQLWriteDSNToIni adds the data source to the [ODBC Data Sources] section of the system information. 然后,它将为数据源创建一个规范部分,并添加一个关键字 (driver) ,其中包含驱动程序 DLL 的名称作为其值。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. 如果 "数据源规范" 部分已存在,则 SQLWriteDSNToIni 会在创建新节之前删除旧部分。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.

如果数据源的名称为默认值,则 SQLWriteDSNToIni 还会在系统信息中创建默认的驱动程序规范部分。If the name of the data source is Default, SQLWriteDSNToIni also creates the default driver specification section in the system information.

只应从安装程序 DLL 调用此函数。This function should be called only from a setup DLL.

有关以下方面的信息For information about 请参阅See
添加、修改或删除数据源Adding, modifying, or removing a data source 安装程序 DLL 中的ConfigDSN () ConfigDSN(in the Setup DLL)
添加、修改或删除数据源Adding, modifying, or removing a data source SQLConfigDataSourceSQLConfigDataSource
从系统信息中删除数据源名称Removing a data source name from the system information SQLRemoveDSNFromIniSQLRemoveDSNFromIni