[英]MS Access Pass-Through Query With "Returns Records: No" Truncates ODBC Connect Str
这是一个非常奇怪的问题,我似乎无法在网络上找到任何其他经历过它的人,但我正在尝试通过 MS Access 2010 传递查询运行 SQL Server UPDATE 存储过程(返回 0 条记录) ,但是当我设置Returns Records: No
它似乎会截断我的 ODBC Connect String 并引发错误!
(括号中的经过消毒的字符串,实际字符串中没有使用括号)
ODBC Connect Str: ODBC;DSN=(dsn name);Description=(description);Trusted_Connection=Yes;DATABASE=(example database name)
首先,设置Returns Records: Yes
允许查询成功执行(通过 SQLServer Mgt Studio 确认)但抛出错误:将Pass-through query with ReturnsRecords property set to True did not return any records.
然后设置Returns Records: No
throws error The Microsoft Access database engine cannot find the input table or query 'ODBC;DSN=(dsn name);Description=(description);Trusted_Connection=Yes;DA'. Make sure it exists and that its name is spelled correctly.
The Microsoft Access database engine cannot find the input table or query 'ODBC;DSN=(dsn name);Description=(description);Trusted_Connection=Yes;DA'. Make sure it exists and that its name is spelled correctly.
因为它可能很重要,我的 DSN 是 8 个字符长,描述是 8 个字符,而数据库是 21 个字符。 我不认为它们太长,并且数据库正在生产中并被多个客户使用,因此此时更改/缩短它们是不可行的。
有没有其他人经历过这个或者其他人可以复制?
我听说 MS Access 对 ODBC 连接 str 有一个内置的 255 个字符的硬限制,但我的肯定是 <100!
我有一个名为qryPass
已保存查询。 它设置为返回记录 = 否。
要使用上面的,在代码中我们可以去:
With CurrentDb.QueryDefs("qryPass")
.SQL = "Exec myStoreProc"
.Execute
End With
在上面,我当然提供了 pass-through sql,但是如果您不需要即时提供 SQL/t-SQL,那么您可以像这样运行上面保存的 pass-though:
CurrentDb.QueryDefs("qryPass").Execute
由于您没有提供关于如何调用此存储过程的 2-3 行代码,因此我们只能猜测您的问题。 不过试试上面的方法。
同样在代码中运行查询之前,请使用 100% 的 UI,创建 PT 查询并尝试运行它(返回记录 = 否)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.