[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Changing Access Database Password - ?

Gary K

5/5/2005 11:40:00 PM

Greetings & Salutations,

I am having a few problems trying to get the .NET data framework to work
properly with Access database files (suprised?)

I breifly investigated using ODBC to connect to my database, however, I was
unable to locate any facilities that would enable me to open a password
protected database file. So there goes that idea.

I found that OLEDB would handle pretty much all of my needs, however, I am
unable to get the password changing SQL statement to work.

I can open a password protected database by adding the "Jet OLEDB:Database
Password" property to the connection string, and OleDbConnection seems to
handle all the other Jet-specific properties. Unfortunately I cannot get the
SQL command "ALTER DATABASE PASSWORD" to work.

I found this little tidbit in the Access documentation, and it will work in
VBA code, but when I use it with .NET I always, ALWAYS, get a "Not a Valid
Password" error (unless I get a syntax error while experimenting). I have
tried using parameters with the command object, constructing a single command
string without parameters & using delimiters of all sorts, no luck.

Can someone please help me work out how to get this to work?, otherwise I'll
have to go back to C++.

I have found the footnote in the documentation that the password changing
SQL statement will only work with the Jet OLE DB provider and ADO, so I
suppose that part of my question is how can I ensure that the OleDbConnection
object is using the right provider. I am using the
"Provider=Microsoft.Jet.OLEDB.4.0" string, and I am having no problems with
any other database function, so what is going on here?

Thanks for reading this far :)
1 Answer

Gary K

5/6/2005 4:58:00 AM

0

Greetings & Salutations,

Ok, I have moved to another development computer & tried it there. A few
problems until I worked out the delimiting schema needed, now I''ll have to
try it on the first computer.

When connecting to the database passwords must(should) be delimited with
double-quotes (""). ie, [Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=db1.mdb;Jet OLEDB:Database Password="<pwd>"]

When setting the password it must(should) be delimited with brackets ([]).
ie, ALTER DATABASE PASSWORD [<newpwd>] [<oldpwd>]

Passwords apparently (not tested yet) have a 20 character limit, must not
contain these characters: "\[]:|<>+=;,.?* , ASCII control codes 10 through
31, and must not have leading spaces.

When sending the SQL command via OleDbCommand, parameters will not work.
Attempting to use parameters will ALWAYS give you an Invalid password error
messages. (May also apply to other forms of command sending).

Thanks to those who read this to help, and I hope Microsoft updates their
documentation soon.