如何在 Excel 365 中建立新的 OLEDB 数据连接

发布于 2025-01-15 08:05:48 字数 914 浏览 4 评论 0原文

看起来是一个愚蠢的问题,但当您想要“获取数据”时,Excel 365 默认会创建新的查询类型连接。我们习惯于在工作中创建与 Oracle、SQL Server 和 MS Access 数据库的 OLEDB 连接,在以前版本的 Excel 中,这始终是数据连接。 Excel 365,默认创建新样式查询(数据选项卡,获取数据 -> 从其他源 -> 从 OLEDB)。 这种新的查询方式不适合我们的需求。我还没有找到任何方法在 Excel 365 中创建旧式数据连接。任何人都可以指导我如何执行此操作吗?

背景:
我们向客户发送包含数据的 Excel 文件,并使用 VB 脚本更改连接字符串和查询,以免发送太多内部信息(表格、连接详细信息、凭据)。因此,我们从 VBScript 文件程序更新数据连接,在其中设置连接字符串,有时还设置命令文本。

我看到的差异:
在查询中,连接字符串类似于“OLEDB:Provider=Microsoft.Mashup.Oledb.1;Data Source = $Workbook$;Location=CURRENT_PERIOD;Extended Properties="”
命令文本是“select * from [Query1]”

在此处更改命令文本会导致错误“[Expression.Error] 导入消耗品与导出不匹配。您是否错过了模块引用?”

在旧的连接样式中,连接字符串为“OLEDB;Provider=MSDASQL.1;DSN=”,命令文本为“select * from current_period”。我们可以随意改变命令文本以获得不同的结果。我们还可以更改连接字符串以包含登录凭据,以便运行查询。

此外,通过更改连接字符串,您可以将连接更改为 OLEDB 连接、ODBC 连接或 MS Access 数据库连接。更改新查询类型连接中的连接字符串会导致错误,并且不会提供不同类型的连接。
它只是不适合我们所做的事情,而且我找不到创建旧式连接的方法。

Looks like a silly question, but Excel 365 defaults to creating a new query type connection when you want to "get data". We are used to creating OLEDB connections to Oracle, SQL server and MS Access databases at work and in previous version of Excel, this was alwas a data connection. Excel 365, defaults to creating a new style Query (Data tab, Get data -> From Other Sources -> From OLEDB).
This new query style does not suit our needs. I haven't found any way to create the old style dataconnection in Excel 365. Can anyone give me pointers how to do this?

Background:
We are sending Excel files with data to customers and we change connection strings and queries using VB Script so as not to send out too much internal information (tables, connection details, credentials). So we update the dataconnection from a VBScript file program where we set connectionstring and sometimes the commandtext.

Differences I see:
In the Query, the connection string is something like "OLEDB:Provider=Microsoft.Mashup.Oledb.1;Data Source = $Workbook$;Location=CURRENT_PERIOD;Extended Properties=""
The commandtext is "select * from [Query1]"

Changing the commandtext here results in an error "[Expression.Error] The import consumables matches no exports. Did you miss a module reference?"

In the older connection style, de connection string is "OLEDB;Provider=MSDASQL.1;DSN=" with commandtext "select * from current_period". We could change the commandtext at will to get different results. We could also change the connection string to include login credentials so the query would run.

Also by changing the connection string you could change the connection to OLEDB connection, ODBC connection or a connection to an MS Access database. Changing the connection string in the new query type connection results in an error and does nog give a different type of connection.
It is just not working for what we do and I can't find a way to create the old style connection.

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

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

发布评论

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

评论(1

蹲在坟头点根烟 2025-01-22 08:05:48

您需要启用旧版导入向导。
转到文件>选项>数据。然后检查所有旧版导入向导。

保存这些设置后,您将看到这些选项出现在“数据”>“数据”下。获取数据菜单。

You need to enable the legacy import wizards.
Go to File > Options > Data. Then check all of the legacy import wizards.

Once these settings have been saved, you will see these options appear under the Data > Get Data menu.

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