使用 C# 在 MS Access 中查找表 [英] Finding Tables in MS Access using C#

查看:57
本文介绍了使用 C# 在 MS Access 中查找表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 c# 确定特定数据库中 MS Access 中的表及其列?

Is it possible to determine the tables and its column in MS Access in a particular database using c#?

有人可以指导我解决这个问题吗?

Can any one guide me in this issue?

推荐答案

根据您连接到 ms-access 文件的方式,您可以以不同的方式读取表和列/字段名称:

Depending on the way you are connecting to the ms-access fiele, you can read tables and column/field names in different ways:

  1. 通过 OLEDB 连接:您可以使用 ADOX 对象集合并读取数据库中可用的表、列、索引等
  2. 使用 ODBC 连接,您可以列出 MS-ACCESS 系统表,打开每个表上的记录集,然后读取所有字段名称.可以使用以下 SQL 指令列出表:

  1. With an OLEDB connecion: you can use the ADOX Objects collection and read tables, columns, indexes, etc available in the database
  2. With an ODBC connection, you can list the MS-ACCESS system tables, open a recordset on each table, and then read all field names. Tables can be listed with the following SQL instruction:

SELECT name FROM MSysObjects WHERE type = 1

SELECT name FROM MSysObjects WHERE type = 1

在所有情况下,一旦通过记录集打开表,您可以通过以下方式读取其字段名称循环记录集对象的字段集合

In all case, once a table is opened through a recordset, you can read its field names by looping on the fields collection of the recordset object

这篇关于使用 C# 在 MS Access 中查找表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆