EntityFrameworkCore.Jet icon indicating copy to clipboard operation
EntityFrameworkCore.Jet copied to clipboard

Error when connecting to Access database (*.mdb)

Open BrandonStudio opened this issue 3 years ago • 10 comments

Microsoft Access database engine could not find "MSysAccessStorage"

Is this means that my database file has something wrong? What can I do then?

Why is it trying to find MSysAccessStorage?

BrandonStudio avatar May 15 '22 03:05 BrandonStudio

Is it a bug using *.mdb database? 'cuz I just reviewed your code and find that perhaps MSysAccessStorage is for *.acccdb and MSysRelationships is for *.mdb

BrandonStudio avatar May 15 '22 03:05 BrandonStudio

Yes, I've confirmed 'cuz the error disappeared when I update my database file to *.accdb

BrandonStudio avatar May 15 '22 03:05 BrandonStudio

@BrandonStudio Is this an exception? If so, please post the full exception, including the stack trace.

Also, please provide us with some context, e.g. is this issue appearing every time you try to connect to the database? What version is the MDB file? Is this an existing file with tables, or is this a new and empty file?

Thanks!

lauxjpn avatar May 15 '22 17:05 lauxjpn

I think that is related to Dual table simulation. You can try to create MSysAccessStorage with one row or create a new table and change the configuration.

bubibubi avatar May 15 '22 18:05 bubibubi

@lauxjpn This has little to do with .NET exceptions.

System.Data.Oledb.OledbException if using Microsof.ACE.OLEDB.12..0 as provider; System.Data.Odbc.OdbcException if using ODBC as provider.

Stacktrace: external code

everytime

I've said the error disappeared when I update the *.mdb file to *.accdb

BrandonStudio avatar May 16 '22 02:05 BrandonStudio

@BrandonStudio We need (at least part of) the stack trace, so we know where in our code the exception is being thrown. This is necessary so that we know when we have reproduced the issue.

Also, please confirm that this issue happens when connecting to the database (meaning, it is the connection process that fails, not the query execution process).

Once we got the requested information from your, we will take a look at it.

Thanks!

lauxjpn avatar May 16 '22 07:05 lauxjpn

I think the problem is very clear

image

Translation:
Microsoft Access database engine could not find table or query matched input "MSysAccessStorage". Please be sure it exists and is spelled correctly —— Stack trace: [External code]

As I have repeated many times. this problem only happens on *.mdb database connection, it disappears when I update the *.mdb file to *.accdb

BrandonStudio avatar May 16 '22 08:05 BrandonStudio

You see MSysAccessStorage should be for *.accdb, not *.mdb: https://github.com/bubibubi/EntityFrameworkCore.Jet/blob/fedc4cc22668d13b96091457539b53fcb79e2412/src/EFCore.Jet.Data/JetConfiguration.cs#L62-L70

BrandonStudio avatar May 16 '22 08:05 BrandonStudio

@BrandonStudio I am aware about the nature of the issue from you first 3 posts.

We still need the stack trace:

To show the [external code] section, refer to What does "external code" in the call stack mean? (basically, click "Show External Code").

The full stack trace should also be available as a property of the Exception object (see Exception.StackTrace Property). You could copy its value from the debug/variable window or from the exception popup in VS.

Another way is to catch the exception and to just log or output it. This would call Exception.ToString(), which would return the exception type, its message and the stack trace:

try
{
    // Code that throws the exception.
}
catch (Exception ex)
{
    Console.WriteLine(ex);
}

By the looks of the two lines of source code you provided in your screenshot, it is likely that the exception is thrown when executing a query, not when connecting to the database, but we will wait for the strack trace to confirm this.


Also, please do not provide screenshots unless there is no other way. Always copy and past text if possible.

lauxjpn avatar May 16 '22 08:05 lauxjpn

Any queries uses Dual table simulation. As far as I remember is a static member and you can change it with a table with a single record. There should be a comment about this setting.

EDIT You can find it here https://github.com/bubibubi/EntityFrameworkCore.Jet/blob/master/src/EFCore.Jet.Data/JetConfiguration.cs

bubibubi avatar May 16 '22 08:05 bubibubi