Friday, March 26, 2004

Well, I guess I'm finally going to start posting some public content here. My particular wish is to help some poor sap like me out there who is googling for info on this or that, and can't find the data. So the post today is going to be about connecting to password protected databases using Visual Studio.Net, C# specifically.

OK, so if you read the docs, and most of the stuff out there, you see all kinds of neat info about how to configure the password of the database using the various methods .Net has to connect to data sources. Further, you know how you can password protect an Access database by opening it exclusively in Access? Well, if you don't, open Access first (but don't open any database) then select File/Open, then browse to the database you want, highlight it, and in the lower right corner hit the dropdown within the "Open" button and select "Open Exclusive" (shouldn't that be "Open Exclusively"?). Anyway do that and you can then get at the password setting feature. Go find that yourself.

So, now you've got this swell password protected database sitting out there on the network, and you're moving to .Net like me and you want to connect, which you've done like one zillion times before using ADO and/or ADOX, but guess what? You're stumped. You ain't opening doodly because you're getting an error like "Connection failed, missing or open exclusively" or some such misleading malarky.

Well the real deal is that you don't use "Password=foobar", you need to use the somewhat difficult to find @"Jet OLEDB:Database Password=foobar;", which I uncovered digging around by creating a blank data connector and looking at the latent attributes, of which there are MANY.

So, there you have it. I hope that helps someone.