简体   繁体   中英

How to access properties of Access Database Table using C# ADOX?

I have created MS Access Database using C# ADOX library. I have created one table with several columns. What I want to achieve is when I insert date in one column, the date format should be YYYY-MM-DD and not MM-DD-YYYY. I know its just display format, but I want to access the property which we set when we open access table in design mode, and for column with date data type, set format as Custom (YYYY-MM-DD). I want this to be set at runtime while creating table only. I wanted to know what should be property name that I should use in order to access and set the format property of column?

You will be better of using DAO library to do that, if you are targetting only Access DB

With DAO, you could open the database, recordset & access this property using Columns(colNumber).Properties("Format").

If you don't know, how to use DAO - let me know.

EDIT: VB6 code using DAO to get the Format property

Dim db As DAO.Database, rst As DAO.Recordset
Set db = OpenDatabase("Path to my MDB file")

Set rst = db.OpenRecordset("select myDateColumn From myTable WHERE 1 = 2")
MsgBox rst.Fields("myDate").Properties("Format").Value

rst.Close
Set rst = Nothing

db.Close
Set db = Nothing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM