0
votes

I have recently taken a project for a client which involves working with their Microsoft Access database programmatically with C# in Visual Studio 2015/2017.

The database opens in my 64-bit version of Microsoft Access 2010 just fine, and I can use/alter all tables/queries perfectly fine. However, when trying to open this .accdb database in Visual Studio, I am getting the dreaded "Unrecognized database format". Now, I do have the Microsoft Office Access database engine for 2007 and 2010 installed, and I am able to open/work with other databases created in Access.

I believe the database was created in Access 2007, as when I open it up, the title of the window contains "(Access 2007 - 2010)", so I'm not sure if that would cause the error or not?

One interesting thing I found was, because I do not need every table in the database, I copied one by one the tables I need into a new database file and checked if I could open this new Access database in Visual Studio. Out of 6 tables that I needed, the last one I needed caused the file to become "unrecognizable" inside Visual Studio.

Why? I have no idea. The table is just like any other, contains lots of columns which either have text, numbers or dates.

My question is, has anybody had a similar experience with this? Could it be the fact that it was made from Access 2007? Why would copying and pasting to a new database then cause that database to be corrupt?

Thanks a lot.

1
SWAG. When copying the problem table (assuming you are using copy/paste), try just pasting the "Table Structure" and see if you can open it in your code. You may have a corrupted Table/Index that the full copy transfers to the new file. - TnTinMn
@TnTinMn Copying and pasting all of the tables with just "Table Structure" still gave me an error. Would this mean that the error lies in maybe some table referencing another table/value, which might not be there? - user2764359
AFAIK, copying "Table Structure" does not import any relations. The only thing that I can think of is that you are somehow using the 2007 ACE driver and the problem table uses a 2010+ feature perhaps a calculated field. I have not worked with that feature, so this is just speculation. Can you post the schema for the problem table? - TnTinMn
Turns out my Debug was set to "Any CPU" inside Visual Studio, I changed it to x64 (my OS and my Office version), and it worked fine. - user2764359

1 Answers

1
votes

There's a difference in the formats. The older format (..2007) is MDB and the later ones (2010...) are ACCDB. If you used any features only available in ACCDB, like attachments, you cannot convert back to MDB and neither will ANY current Microsoft tool other than Access open it. Strange but true.

Painful is to exclude those tables or forms that use the new features and then do the conversion.....sigh.....