如何获取 MS Access 数据类型列表?
我试图在 C# 程序的组合框中列出 Microsoft Access 2000-2007 中的数据类型(取决于 MS Access 数据库版本)。 我怎样才能实现这样的目标?
I am trying to list data types from Microsoft Access 2000-2007 (depending on the MS Access database version) in a combobox for a C# program. How can I achieve such a thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为不可能在运行时询问引擎来枚举它支持的数据类型。 例如,DAO 不会显示某些 Jet 4.0 数据类型,例如
NCHAR
和BINARY
; ADO将揭示Access数据库引擎从未支持的数据类型; 只有 ACEDAO 会显示多值类型。我认为您需要提前了解每个版本的引擎支持的数据类型,然后在运行时选择适当的集。
Jet 4.0 数据类型(Access2000 到 2003 包括在内)和各种同义词可以在 这里(还应该给出一些有关 Jet 4.0 新增类型的提示,以防万一您需要支持早期版本的引擎)。
ACE(Access2007)添加了附件类型; 还有多值(“复杂”)类型,以支持 SharePoint 列表:我认为您需要自己决定多值类型是不同的类型还是仅仅是现有类型的变体。 Access2007 帮助中有一些详细信息。
I don't think it is possible to interrogate the engine at run time to enumerate the data types it supports. For example, DAO will not reveal some of the Jet 4.0 data types such as
NCHAR
andBINARY
; ADO will reveals data types that the Access database engine has never supported; only ACEDAO will reveal multivalued types.I think you need to know in advance the data types each version of the engine supports then select the appropriate set at run time.
Jet 4.0 data types (Access2000 to 2003 inclusive) and the various synonyms can be found here (should also give some hints about which types are new to Jet 4.0, just in case you need to support earlier versions of the engine).
ACE (Access2007) added an Attachment type; also multivalued ("complex") types in order to support SharePoint lists: I think you will need to decide for yourself whether multivalued types are distinct types or merely variations on existing types. There are some details in the Access2007 Help.
Microsoft.Office.Interop.Access.Dao.DataTypeEnum
当然,您需要添加引用,我绝对讨厌添加对 Office 的引用,因为您会与 Office 版本绑定,而且我讨厌每次升级时更新代码。
Microsoft.Office.Interop.Access.Dao.DataTypeEnum
Of course, you'll need to add a reference, and I absolutely hate adding reference to Office because you get tied to a version of Office,and I hate updating code every time we upgrade.