none
ADOX

    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;

    cat.Tables.Append(tblNew);

    Please help me to set Format propety to date column

    Thanks,

    Vara

    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

    http://allenbrowne.com/ser-49.html -- and you might be better off not using ADOX, see appropriate references here http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1604591&SiteID=1.

     

    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
    =Format(Fields!AdmitDate.Value,"MM/dd/yy")

     

     

    ... 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.)

     

    >L<

     

     

    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,

    Vara

     

    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.

     

    >L<

    Saturday, June 30, 2007 3:19 PM