发布ODBC程序时,如何建立ODBC Data Source?

benage 2000-06-19 12:31:00
程序中用到ODBC或ADO,发布时如何使安装程序在目标系统上建立ODBC Data Source?
...全文
459 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
benage 2000-06-21
  • 打赏
  • 举报
回复
就DSN而言,wingsun是对的,通过细查MSDN实现了。wjf的方法应该也可,不知兼容性如何。
但安装驱动程序时遇到困难,QLConfigDriver 之类的API没用明白。后来发现installshield 带的一个template提供全部手段,完整、规范。最终采用这个办法。
谢谢wingsun和wjf.
wjf 2000-06-19
  • 打赏
  • 举报
回复
最简单的办法是直接写注册表;
HKEY_LOCAL_MACHINE\software\ODBC
HKEY_LOCAL_MACHINE\software\ODBC.INI
Wingsun 2000-06-19
  • 打赏
  • 举报
回复
你可以写一个DLL,在Install Shield中调用他来完成工作。使用的是ODBC API SQLConfigDataSource,为Install Shield写扩展DLL可以在Install Shield中找到相关的帮助和例程。

SQLConfigDataSource adds, modifies, or deletes data sources.

Syntax

BOOL SQLConfigDataSource(
HWND hwndParent,
WORD fRequest,
LPCSTR lpszDriver,
LPCSTR lpszAttributes);

Arguments

hwndParent

[Input]
Parent window handle. The function will not display any dialog boxes if the handle is null.

fRequest

[Input]
Type of request. fRequest must contain one of the following values:

ODBC_ADD_DSN: Add a new user data source.

ODBC_CONFIG_DSN: Configure (modify) an existing user data source.

ODBC_REMOVE_DSN: Remove an existing user data source.

ODBC_ADD_SYS_DSN: Add a new system data source.

ODBC_CONFIG_SYS_DSN: Modify an existing system data source.

ODBC_REMOVE_SYS_DSN: Remove an existing system data source.

ODBC_REMOVE_DEFAULT_DSN: Remove the default data source specification section from the system information. It also removes the default driver specification section from the ODBCINST.INI entry in the system information. (This fRequest performs the same function as the deprecated SQLRemoveDefaultDataSource function.) When this option is specified, all of the other parameters in the call to SQLConfigDataSource should be NULLs; if they are not NULL, they will be ignored.

lpszDriver

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

lpszAttributes

[Input]
List of attributes in the form of keyword-value pairs. For more information, see ConfigDSN in Chapter 22, “Setup DLL Function Reference.”

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧