Sure.
connectionString is in the "Data Source=xxx;Password=xxx;" format.
Here is a sample method that uses the connection string:
public int ExecuteNonQuery(string query) {
using(SQLiteConnection conn = new SQLiteConnection(connectionString))
{ conn.Open(); using(SQLiteCommand cmd = new
SQLiteCommand(query, conn)) { int result =
cmd.ExecuteNonQuery(); conn.Close();
return result; } } }
It works perfectly when the database is initially created or subsequently
accessed.
Here is the changepassword code:
// DOES NOT WORK public bool ChangePassword(string newPassword) {
try { using (SQLiteConnection conn = new
SQLiteConnection(connectionString)) {
conn.Open(); conn.ChangePassword(newPassword); // Also tried
null as String then another call to changepassword
conn.Close(); } } catch (SQLiteException
e) { exceptionMessage = e.Message;
return false; }
return true; }
When a query is executed, it always uses current password. After the above code
is called, neither the old or the new password work.
One temporary solution I have found is that I just create a new database with
the desired password and transfer all the contents from the old database to it.
After that, i simply delete the original database. The problem with this
process is that the database file creation date changes every time the password
changes.
Again, it is possible that I am still doing something wrong with the coding but
at this point I am not sure.
> From: [email protected]
> To: [email protected]
> Date: Sat, 22 Oct 2011 20:39:09 -0700
> Subject: Re: [sqlite] ChangePassword method problem
>
>
> Farhan Husain wrote:
> >
> > I have tried opening all encrypted databases using both the SetPassword
> method
> > and the password property in the connection string. No matter what
> combination I
> > use, after the password is changed using ChangePassword method, the
> database
> > becomes unreadable using the updated or previous password.
> >
>
> I've added some more unit tests to the test suite to verify that this
> feature works
> as documented and I'm not seeing any issues. Could you post some simplified
> C# code
> that demonstrates the behavior you are seeing?
>
> --
> Joe Mistachkin
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users