I'm open to suggestions on what might be done to clarify things.
For now the solution to the problem as I've implemented it (still pending CVS checkin) is to require that you either use the Password=xxxx syntax in the ConnectionString, or call SetPassword() before you call Open() instead of after.
The problem stems from the fact that right after a connection is opened, I have to execute 3 pragma's on the database file to set the cache size, page size and synchronous mode. If the password isn't already set for an existing database when I do this, then SQLite throws an error.
There are several important scenarios that have to be covered in any change to the password methods:
- A new database is created and you want to encrypt it
- You have a database already populated and you need to encrypt/decrypt it
- You have an encrypted database that you want to open
For cases 1 and 3, you can use SetPassword(). Additionally, under the new changes I just made, you could call ChangePassword() for scenario #1 as well.
For case 2, you *have* to call ChangePassword() on an open database, which means the database must've been opened and SetPassword() must've already been called.