Reputation: 1998
I'm trying to open an access database with the extension .accdb so I can read some information from this database. I have no problem doing this, if I use the wizard:
However when try to use code to do this I always get an exception when I try to connect:
From debugging I understood that the exception comes from not having opened the connection. So I open the connection but the the database comes as empty:
I have looked around stack overflow and tried to apply many of the answers to similar questions but they haven't worked. In theory if I can connect through the wizard I should also be able to connect through OleDBConnection object in C#. How can I fix this?
Upvotes: 0
Views: 141
Reputation: 1998
I found the problem. My table name had a space between "Tab_Project Data" and because I didn't use [] it was looking for a table named "Tab_Project" which it couldn't find. So I just had to put "[Tab_Project Data]" inside my query and now it works.
Upvotes: 1