views:

642

answers:

1

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?

A: 

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
shahkalpesh