写入 accpac 中的 sql 数据库
我有一个由 AccPac 运行的 VB 脚本。我想将错误日志添加到脚本中。我希望将该日志存入数据库。 我听说不可能从 VB 脚本连接到 SQL 数据库。我想证明这种不可能是错误的。
所以我的问题是这样的。
有人通过 accpac vbscript 将 sql 运行到 sqlserver 数据库吗?如果是的话,他们能给我一些线索,告诉我他们是如何完成这样一个“不可能”的任务的吗?
I've got a VB script that's being run by AccPac. I want to add error logging to the script. I'd love to have that log go to a database.
I've heard it's impossible to connect to a SQLdatabase from the VB script. I'd like to prove this impossibility wrong.
So my question is this.
Has anyone run sql to a sqlserver database via an accpac vbscript? If so could they give me a clue as to how they accomplished such an "impossible" task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Accpac 实际上使用 VBA 而不是 VBScript(尽管语法几乎相同)。我在 Accpac 中完成了许多 VBA 宏,它们使用 SQL 数据库来完成比日志记录更复杂的任务。该过程与具有 VBA 宏的 MS Office 文件相同。您必须通过“工具>参考”添加“Microsoft ActiveX Data Objects 2.8 Library”或类似的参考。然后您就拥有了一个可用于通过 ODBC 连接的
ADODB
对象。查看与 Excel 相关的问题 Accessing SQL Database in Excel-VBA
请注意,从 Accpac 6 开始,Sage 不再使用桌面客户端,您的 VBA 宏将无法在门户中使用。
Accpac actually uses VBA and not VBScript (although the syntax is almost identical). I have done lots of VBA macros in Accpac that use SQL databases for much more complex tasks than just logging. The process is the same as with MS Office files that have VBA macros. You have to add "Microsoft ActiveX Data Objects 2.8 Library" or similar as a reference via "Tools > References". You then have an
ADODB
object you can use to connect via ODBC.Check out this question relating to the same thing with excel Accessing SQL Database in Excel-VBA
Please note that starting from Accpac 6, Sage is moving away from the desktop client and your VBA macros wont work with the portal.
在较新的 Sage 300 (Accpac) 版本中,有一个带有 Roto“CS0120”的视图。它可以帮助您直接在数据库上运行 SQL 查询(插入/选择/更新)。只需在 VB 代码中将其作为常规视图打开,将查询字符串设置为浏览过滤器并调用 Fetch。
In newer Sage 300 (Accpac) versions, there is a view with Roto "CS0120". It can help you to run SQL queries directly on database (insert/select/update). Just open it as regular view in your VB Code, set your query string as Browse filter and call Fetch.