Follow @RoyOsherove on Twitter

Avoiding DB_SEC_E_AUTH_FAILED exception on connection string

Thought I should share, since i could find almost no reference to this on the web...

I came accross this weird message when trying to set the connection string on the connection object to point to an MDB file on my drive, using this connection string:

@"Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data Source=C:\Documents and Settings\royo\My Documents\WOZ.mdb;Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"

The way to repair it is pretty simple:

Notice that I put a '@' at the start to format the string correctly, since it contains double quotes and stuff. Appearently, this is not enough. to fix this you need to replace each pair of double quotes to 2 pairs of double quotes like so:

Password="";   turns into Password="""";

repeat this for all values containing double quote pairs in the string and your done.

and that should fix it

 

 

Replace all double

BBS, Telix And World Domination

MSFT to compete with Google