Issues with creating columns of a DataType in MS access database using ADOX and visual RRS feed

  • Question

  • I am having issues with creating columns in a database. I specify the data type of the column using the ADOX.DataTypeEnum, but when i open my database using MS access, the column's data type is always text.

    In my code the "ID" column should be an integer data type and the "Date" column should be a date Data type. However they show up as text data type in MS access.

    Here is a snapshot of my code

    ADOX.CatalogClass cat = new ADOX.CatalogClass();
        // create database
        cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
                   "Data Source= ..\\Diagnostic\\ErrorLog.mdb;" +
                   "Jet OLEDB:Engine Type=5");
        ADOX.Table table = new ADOX.TableClass();
        table.Name = "Errors";

        CreateColumns(table, "ID", ADOX.DataTypeEnum.adInteger, 1);
        CreateColumns(table, "Description", ADOX.DataTypeEnum.adChar, 40);
        CreateColumns(table, "Date", ADOX.DataTypeEnum.adDate, 10);
        CreateColumns(table, "Ticks", ADOX.DataTypeEnum.adChar, 10);
        CreateColumns(table, "Details", ADOX.DataTypeEnum.adChar, 40);


        //MessageBox.Show("Database Created Successfully");

    // Creates columns for table
    private void CreateColumns(ADOX.Table table, String name, ADOX.DataTypeEnum type, int size)
          ADOX.Column column = new ADOX.Column();
          column.Name = name;
          table.Columns.Append(column, type, size);

    Tuesday, May 15, 2007 10:47 PM