Larry, After some further testing where I created a clean DB and everything worked, I think you were correct that it was/is my DB file. I opened and closed the db using a third party tool and voila, no more bugs. Now to figure out how I screwed the state up in the first place!
As for exception handling, cut me some slack, it's just a demo ;) Phil -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Larry Brasfield Sent: Friday, February 03, 2012 11:12 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Error 21 on Open (C#) Phil Whalen wrote: > I've run into a bug where the second time I attempt to connect to a database, > it fails. No exception is thrown but "SQLite error (21): misuse at line > 110832 of [a499ae3835]" pops out in the console. > > After distilling the problem down, I've found that this code will always > reproduce the error: > > > public Boolean TestConnection() > { > try > { > using (SQLiteConnection conn = new SQLiteConnection("Data > Source=agilent.db")) > { > conn.Open(); > > Thread.Sleep(100); > > conn.Close(); > } > } > catch (Exception e) > { > return false; > } > return true; > } > > The function will always return true, but the second time (and all future > times) you run it, the error (21) comes out on the console. Any operations on > the db will fail at that point. > > There must be something really obvious I'm missing here. The using statement > should dispose the connection, and I'm calling close. Is there some flag I'm > missing? > > (using VS 2010, C#/WPF, latest System.Data.SQLite.dll) > > Any guidance appreciated. > > Phil > Using the .NET framework 4, I cannot reproduce your problem. Calling an exact copy of your TestConnection() method 4 times in succession produces no error. (It produces no "agilent.db" file either, so your problem must relate to the state of that database, somehow.) I think you need to reduce your program to something more than you've shown, that gets the DB file to some state that is different the 2nd time through. I see nothing wrong with the code you did show. (Well, swallowing exceptions so mutely is a bit lame!) -- Larry Brasfield _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users