• Question

  • Hi All,


    I am facing problem with ADOX to set Date field property of MSAccess table throught C# programmatically.

    Please can any one help.

    Sample code i am using now.

    ADOX.Table tblNew = new ADOX.TableClass();

    tblNew = new ADOX.TableClass();

    tblNew.Name = "tbl_Table";

    tblNew.ParentCatalog = cat;

    tblNew.Columns.Append("PatientAccountNumber", ADOX.DataTypeEnum.adWChar, 30);

    tblNew.Columns.Append("PatientType", ADOX.DataTypeEnum.adWChar, 100);

    tblNew.Columns.Append("AdmitDate", ADOX.DataTypeEnum.adDate, 10);

    tblNew.Columns["AdmitDate"].Properties["Nullable"].Value = true;

    //tblNew.Columns["AdmitDate"].Properties["Format"].Value = "MM/dd/yy";

    tblNew.Columns.Append("DischargeDate", ADOX.DataTypeEnum.adDate, 10);

    tblNew.Columns["DischargeDate"].Properties["Nullable"].Value = true;

    tblNew.Columns.Append("AccidentDate", ADOX.DataTypeEnum.adDate, 10);

    tblNew.Columns["AccidentDate"].Properties["Nullable"].Value = true;


    Please help me to set Format propety to date column



    Thursday, June 28, 2007 11:13 AM

All replies

  • Mapping to Access types using ADOX requires that you use appropriate Access types.  Here is a nice table -- and you might be better off not using ADOX, see appropriate references here


    I'm saying this because it isn't clear from your question whether the data type itself is throwing an error or whether you're just having trouble formulating the format string correctly to get the result you want?


    Assuming the type is mapping okay, you've posted in the Report Controls section... is your problem that you need to display the date in a report? In which case, try


    Code Snippet



    ... in the textbox expression instead. (And if the AdmitDate isn't coming across as a datetime, throw a CDATE() in there before doing the format -- although in your case it probably is.)





    Thursday, June 28, 2007 3:46 PM
  • Hi Lisa Nicholls,


    I am very sorry for not clear in my question. Actually my question is, while creating Access table using ADOX I want to set date format to my custom format. that is commented in my above given code snippet. I am sorry to post it in Report control section.

    Can any one help this?


    Thank you,



    Friday, June 29, 2007 5:22 AM
  • Hi Vara,


    You need to re-post in an Access forum, then, although the links I gave you may be of some help.  When you re-post, be sure to let people know whether you are getting an error or if the format you are using just isn't working.



    Saturday, June 30, 2007 3:19 PM