0

我已经使用 C# ADOX 库创建了 MS Access 数据库。我创建了一个包含几列的表。我想要实现的是当我在一列中插入日期时,日期格式应该是 YYYY-MM-DD 而不是 MM-DD-YYYY。我知道它只是显示格式,但我想访问我们在设计模式下打开访问表时设置的属性,对于日期数据类型的列,将格式设置为自定义(YYYY-MM-DD)。我希望仅在创建表时在运行时设置它。我想知道应该使用什么属性名称来访问和设置列的格式属性?

4

1 回答 1

0

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
于 2009-07-20T20:04:19.220 回答