Limits of OLEDB and Access Passwords


People that know me know I hate useless error codes. During code reviews if I see someone attempting to return E_FAIL I will often launch into a blistering remark about how they are being lazy and making other developer’s lifes harder all at the same time.  The problem with E_FAIL is that it is completely unactionable; it gives the caller (or the end user) zero details about what failed or how to fix it.

Given this, you can imagine the distaste in my mouth when I encountered a DB_E_ERRORSOCCURRED (0x80040E21) error while just trying to open an Access database using OLE (via CDataSource/CSession). I get this error back with no fanfare about what the actual problem is. The connection string used looked something like this:

PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=database.accdb;Jet OLEDB:Database Password=’ O1i6PidNWwKFHhl6DWJa7UZjD8RiPZ’

 

After blindly fishing around, I narrowed it down to the actual password that was the issue. If I disable the password protection on the database, I could connect just fine.

After hacking around some more I discovered that it is the length of the password (and not the any specific characters) which cause the open operation to fail. My life could have been so much happier if I had received a specific error message, or even an overloaded one which would help point to the length of the password as an issue. Looking through the standard windows headers, there are a handful of existing errors that would have been much nicer to see than an “errors occurred” message.

So, if you happen to run into this error code yourself, you may need to shorten the password to fewer than 20 characters.

Comments (1)

  1. admin says:

    perfect resolution.

    went through a 100 other postings.

    you hit the problem on the head.

Skip to main content