如何在 C# 中使用 OleDB 列出 MS Access 文件中的所有查询?
我有一个包含 200 个查询的 Access 2003 文件,我想打印出它们在 SQL 中的表示形式。 我可以使用设计视图查看每个查询并将其剪切并粘贴到文件中,但这很乏味。 另外,我可能需要在其他 Access 文件上再次执行此操作,因此我肯定想编写一个程序来执行此操作。
Access 数据库中的查询存储在哪里? 我找不到任何说明如何获取它们的内容。 我对 Access 不熟悉,所以我很感激任何指点。 谢谢!
I have an Access 2003 file that contains 200 queries, and I want to print out their representation in SQL. I can use Design View to look at each query and cut and paste it to a file, but that's tedious. Also, I may have to do this again on other Access files, so I definitely want to write a program to do it.
Where are queries stored an Access db? I can't find anything saying how to get at them. I'm unfamiliar with Access, so I'd appreciate any pointers. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
过程就是您要查找的内容:
这将为您提供一个包含以下列(以及其他列)的 DataTable:
PROCEDURE_NAME:查询的名称
PROCEDURE_DEFINITION:SQL 定义
因此,您可以像这样循环遍历该表:
Procedures are what you're looking for:
This will give you a DataTable with the following columns in it (among others):
PROCEDURE_NAME: Name of the query
PROCEDURE_DEFINITION: SQL definition
So you can loop through the table like so:
您可以使用 OleDbConnection 的 GetSchema 方法以及 Remou 发布的有关 ADO 架构的内容将其放在一起
哎呀忘记了链接:MSDN
you can put this together using the OleDbConnection's GetSchema method along with what Remou posted with regards to the ADO Schemas
oops forgot link: MSDN
如果您想手动进行快速查询。
In case you wanted to do a quick query by hand.
不是 C# 语言,但可能是一个不错的起点:
http://www.datastrat.com /Code/DocDatabase.txt
Not in C#, but may be a good place to start:
http://www.datastrat.com/Code/DocDatabase.txt