I want to create programatically a database and I create into that database a table.(.MDB Access database) I create the database and the table using the ADOX integrated functions, "Catalog" for the database and "Table" for the table inside the db.
Table tabelreceptii = new Table();
tabelreceptii.Name = "Receptii";
tabelreceptii.Columns.Append("NumarReceptie", DataTypeEnum.adVarWChar, 10);
tabelreceptii.Columns.Append("DataReceptie", DataTypeEnum.adDBDate);
cat2.Tables.Append(tabelreceptii);
When I try to run the app, occurs the "Type is invalid." error, with the error code "ErrorCode=-2147217859".
I realized that the problem is in this part of code:
tabelreceptii.Columns.Append("DataReceptie", DataTypeEnum.adDBDate);
The adDBDate type seems not working in my case, and I really need a DATE column in my table. Any solutions?
There is a difference between adDBDate and adDate types as explained here. Choose the type that represents the data that you have or expect to use.
adDate: Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
adDBDate: - Indicates a date value (yyyymmdd) (DBTYPE_DBDATE).