指定 ODBC 的默认驱动程序

发布于 2024-07-19 19:23:17 字数 739 浏览 4 评论 0原文

我有一个旧版 VB6 应用程序,它根据配置文件中的参数构建 DSN。 该参数是一个 ODBC 连接,该连接有一个名称 (DSN-NAME),它将服务器 (DBSERVER) 映射到驱动程序(“SQL Server Native Client”)。

一般来说,它构建的DSN是这样的:

DSN=DSN-NAME;用户=foo;密码=bar

如果我在文件中指定主机名,它会构建一个连接字符串,其中显示

DSN=DBSERVER;用户=foo;密码=bar

报错信息为:

[Microsoft][ODBC 驱动程序管理器] 未找到数据源名称且未指定默认驱动程序

这对我来说可能有一种指定默认驱动程序的方法,这可能意味着我可以仅在配置文件中指定服务器名称,并且不需要创建 ODBC 连接。

(我知道这些可以自动创建;这只是为了简单安装,并满足我的好奇心)。

如何指定默认驱动程序? 如果我可以将默认驱动程序设置为 SQL Server Native Client,我可以说 DSN=DBSERVER 并连接吗?

编辑:重点是尝试在不更改连接字符串的情况下执行此操作。 所有研究都表明这实际上是不可能的,但他在对话中的措辞表明这可能是可能的。

I have a legacy VB6 app which builds a DSN based on a parameter in a config file. The parameter is an ODBC connection, and the connection has a name (DSN-NAME) which maps a server (DBSERVER) to a driver ("SQL Server Native Client").

Generally, it builds a DSN like this:

DSN=DSN-NAME;User=foo;Password=bar

If I specify a hostname in the file, it builds a connection string which says

DSN=DBSERVER;User=foo;Password=bar

The error message reported is:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

This suggests to me that there is perhaps a way of specifying a default driver, which may mean I can specify just the server name in the config file, and not need to create the ODBC connection.

(I am aware these can be created automatically; this is just to simply installation, and to satisfy my curiosity).

How do you specify a default driver? If I can set the default driver to SQL Server Native Client, can I then say DSN=DBSERVER and connect?

Edit: the point was to try and do this without changing the connection string. All the research suggested this isn't actually possible, but he wording of the dialog suggested it might be.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

尴尬癌患者 2024-07-26 19:23:17

我遇到了同样的问题,并通过使用 32 位 ODBC 管理器创建 32 位 DSN 来修复它,而不是使用管理工具中的 64 位管理器,后者仅创建不起作用的 64 位 DSN。

32 位 ODBC 管理器位于 C:\Windows\SysWOW64\odbcad32.exe

请参阅这篇文章 "数据未找到源名称且未指定默认驱动程序”

I had the same problem and fixed it by using the 32-bit ODBC admin to create a 32-bit DSN rather than the 64-bit admin in Administrative Tools which only creates 64-bit DSN which don't work.

The 32-bit ODBC Manager is located at C:\Windows\SysWOW64\odbcad32.exe

See this article "Data source name not found and no default driver specified".

两仪 2024-07-26 19:23:17

要指定默认驱动程序,请在连接字符串中使用 DRIVER=:

DRIVER=driver name here;DATABASE=mydb;USER=foo;PASSWORD=bar

驱动程序名称是显示在控制面板 ODBC 配置工具中的每个驱动程序的名称。 请注意,您需要提供通常来自 DSN 的信息,在本例中为数据库名称。

To specify a default driver, use DRIVER= in the connection string:

DRIVER=driver name here;DATABASE=mydb;USER=foo;PASSWORD=bar

The driver name is the name that appears in the Control Panel ODBC config tool for each driver. Note you will need to supply the info which would normally come from the DSN, in this case the database name.

栀梦 2024-07-26 19:23:17

您可以通过将“;SERVER=dbserver”附加到连接字符串来实现您想要的目的。

您的 DSN 中已指定了一个服务器,但连接字符串中的 SERVER 关键字将覆盖该服务器。

http://msdn.microsoft.com/en-us /library/ms715433(VS.85).aspx

You can achieve what you want by appending ";SERVER=dbserver" to your connection string.

There is already a server specified in your DSN, but the SERVER keyword in your connectionstring will override that.

http://msdn.microsoft.com/en-us/library/ms715433(VS.85).aspx

活雷疯 2024-07-26 19:23:17

使用无 DSN 连接字符串...它可以“即时”创建以完全满足您的目的...无需使用 odbcad32.cpl 或 reg/ini 文件来控制/配置所需的 dsn。

请参阅 http://support.microsoft.com/kb/147875

有关详细信息,

Use a DSN-less connection string...it can be created 'on the fly' to exactly suite your purposes....no piddling with odbcad32.cpl or reg/ini files to control/configure a dsn required.

see http://support.microsoft.com/kb/147875

for details

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文