【发布时间】:2014-11-03 03:06:37
【问题描述】:
我在几个 *.mdb 文件中有几个 MS-Access 查询。它们非常复杂。
所以我只想打开一个文件,运行其中包含的特定查询并返回结果表。
我该怎么做?
(我知道我们可以通过连接字符串等进行连接,但我想通过这种方式进行探索。)
我的示例代码(经过编辑以禁用安全警报):
using Microsoft.Office.Interop.Access;
using Microsoft.Office.Core;
var app = new Application();
app.OpenCurrentDatabase(@"C:\test.mdb", true);
app.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityLow;
app.Visible = false;
// run query
app.Quit();
示例查询:
select date(), date()-1
【问题讨论】: