Ok, so I created a simple program to test the changepassword method. Here it is:
using System;using System.IO;using System.Text;using System.Data.SQLite;
namespace SQLiteTest{ class Program { static void Main(string[]
args) { // Create an encrypted database string
connectionString = "Data Source=test.db; Password='password'";
using (SQLiteConnection conn = new
SQLiteConnection(connectionString)) { conn.Open();
// Explicitly close the connection conn.Close();
}
// Open and close the database again using
(SQLiteConnection conn = new SQLiteConnection(connectionString)) {
conn.Open(); // Explicitly close the connection
conn.Close(); }
// Open, change the password and then close the database
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{ conn.Open();
conn.ChangePassword("changed");
// Explicitly close the connection conn.Close();
}
// Try to open and close the database again
connectionString = "Data Source=test.db; Password='changed'";
using (SQLiteConnection conn = new
SQLiteConnection(connectionString)) { // CRASHES HERE
WITH EXCEPTION // File is not a database
conn.Open(); // Explicitly close the connection
conn.Close(); }
// Delete the database file if (File.Exists("test.db"))
File.Delete("test.db"); } }}
It basically works all the way up to the "CRASHES HERE" part. Now, if the
password had actually changed then the program should work but unfortunately it
doesn't (or something else is going wrong). Again, Maybe I am doing something
incorrectly so I kept it simple just to check.
Visual Studio 2010, Debug x86, .NET 4.0 Client Profile,
sqlite-netFx40-binary-bundle-Win32-2010-1.0.76.0
Thanks..
> From: [email protected]
> To: [email protected]
> Date: Mon, 24 Oct 2011 03:55:03 +0000
> Subject: Re: [sqlite] ChangePassword method problem
>
>
> Sorry, I should clarify, I meant the chances of the database corruption. You
> are right, in a properly designed system the access to the database would
> take into account a changed password, which would be the normal scenario.
> But, if there is even a small possibility that a database would be
> "corrupted" because of an extraneous connection (regardless of how well the
> system is designed), then it could be a problem. The database being
> unreadable due to a wrong password is good because it is functioning the
> right way like you stated. It shouldn't however become corrupt.
> Again, I am quite sure it is simply something that I am doing wrong on my end
> so I need to revisit all the codepaths for this procedure in my code.
> Thanks!
>
> > From: [email protected]
> > Date: Mon, 24 Oct 2011 04:45:24 +0100
> > To: [email protected]
> > Subject: Re: [sqlite] ChangePassword method problem
> >
> >
> > On 24 Oct 2011, at 4:42am, Farhan Husain wrote:
> >
> > > So, I was just wondering how you would deal with multiple processes
> > > accessing the database. You can't guarantee that all would be closing the
> > > connection properly. It would seem that if all connections needed to be
> > > closed before a proper changepassword call can take place, then the
> > > chances of database corruption would increase in a
> > > multi-process/multi-access environment.
> >
> > How did you expect it to work when you designed the system ? After all,
> > changing the password to a database when lots of other processes are
> > reading it would naturally cause problems for those processes. They would
> > all suddenly start generating errors because they'd be unable to access
> > their data.
> >
> > Simon.
> > _______________________________________________
> > 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
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users