检索 MSAccess 数据库列描述
我有一个 MS Access 2002-2003 数据库。我想知道是否有一种方法可以以编程方式检索列描述。我已经可以使用获取列类型、名称等,
OleDbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
DataTable schemaTable = reader.GetSchemaTable();
foreach (DataRow myField in schemaTable.Rows)
{
foreach (DataColumn myProperty in schemaTable.Columns)
{
// etc...
}
}
但无法访问“描述”信息(您可以在 MSAccess 中使用“设计视图”时查看该信息)。
有没有简单的方法来获取“描述”信息?
I have an MS Access 2002-2003 database. I'd like to know if there's a way to programmatically retrieve the column descriptions. I can already obtain the column type, name, etc. using
OleDbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
DataTable schemaTable = reader.GetSchemaTable();
foreach (DataRow myField in schemaTable.Rows)
{
foreach (DataColumn myProperty in schemaTable.Columns)
{
// etc...
}
}
but I don't have access to the "Description" information (which you can view when using "Design View" in MSAccess).
Is there a simple way to get the "Description" information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我最终所做的:
这非常有效,只是我在找到正确的程序集以添加为引用时遇到了一些麻烦。我必须添加对adodb.dll(.Net 附带的)的引用。我还必须添加对 Microsoft ADO Ext 的引用。 2.8 用于 DDL 和安全,它是一个 ActiveX 组件(在 Visual Studio 中添加引用时可在 COM 选项卡中找到)。
代码片段很棒,但如果您省略参考信息,有些人就会陷入困境;)
Here's what I ended up doing:
This works great, except I had some trouble finding the right assemblies to add as references. I had to add a reference to adodb.dll (which comes with .Net). I also had to add a reference to Microsoft ADO Ext. 2.8 for DDL and Security which is an ActiveX component (found in the COM tab when adding references in Visual Studio).
Code snippets are great, but if you omit reference information, some people get stuck ;)
使用 ADOX 目录,您可以查看 VBA 中的字段属性“说明”:
复制 如何在 C# 中从 Access 数据库检索列描述?
Using an ADOX catalogue, you can look at the field property Description, in VBA:
copy from How can I retrieve column descriptions from an access database in C#?