Hello! 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?
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.
There are some lists and refrences here http://wiki.lessthandot.com/index.php/Determine_Field_Type that may help.
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
and BINARY
; 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.