in

System.Data.SQLite

An open-source, enhanced version of the SQLite database engine for Windows

"Unable to open the database file"

Last post 07-04-2008 6:32 AM by Funcky. 36 replies.
Page 3 of 3 (37 items) < Previous 1 2 3
Sort Posts: Previous Next
  • 01-20-2008 5:08 PM In reply to

    Re: "Unable to open the database file"

    I have found out, that this issue occurs only under Windows Vista and only if i put my database file into the AppData folder. I have no idea what Vista does with the database file that it blocks access to it or its folder so that sqlite cannot create a journal file. I have no antivirus software running and i have disabled indexing service. I have also noticed that this exception occurs often if i create command objects and execute sql statements inside of the using(...) block. Is there any way to grant sqlite exclusive access to the database file so that no other process can open it for writing?

  • 02-08-2008 2:54 AM In reply to

    Re: "Unable to open the database file"

    Hi. I have this error message as well. Now here's the thing:

    It never happens when debugging or at any other filesystem location on machines with the development environment (Visual C# Express 2005). It however fails to open the database on any (tested) system without Visual. I've double checked the db-path in the connection string, it's always correct...

     Here's the relevant code (trivial, but just in case) :

                private SQLiteConnection m_Conn = new SQLiteConnection("Data Source=" +        Path.GetDirectoryName(Application.ExecutablePath) + "\\db\\default.db");

                MessageBox.Show(m_Conn.ConnectionString);
                m_Conn.Open();

    Any Ideas?

  • 02-08-2008 7:36 AM In reply to

    Re: "Unable to open the database file"

    Easiest thing to do is to try and open the file for read/write access using File.Open().  If that succeeds and the connection fails, then we have a real problem.

  • 02-08-2008 9:31 AM In reply to

    Re: "Unable to open the database file"

    I have tried to open the database file in external editor when there were database connections established from my application. If i modify the file and save it, the database connection is broken. The thing is, that any other program can access database file and block/modify it at any time, what can cause my application to loose database connection. And from the process of my application i could also open the database file in shared read/write mode. Any suggestions to avoid blocking of the database file?

  • 04-06-2008 1:20 AM In reply to

    • juvi
    • Top 10 Contributor
    • Joined on 02-03-2006
    • Posts 35

    Re: "Unable to open the database file"

     hello,

     I just wanted to ask you if this problem is allready fixed or not, because I am now also running into this problem if I install my software under partition C: under Windows Vista.

     thx

    juvi 

  • 06-04-2008 2:54 PM In reply to

    Re: "Unable to open the database file"

     See http://www.nabble.com/forum/ViewPost.jtp?post=17656998&framed=y

  • 07-04-2008 6:32 AM In reply to

    • Funcky
    • Not Ranked
    • Joined on 07-04-2008
    • Posts 1

    Re: "Unable to open the database file"

     Hello, I got the same error message :

    It append in a web application. When I try on my computer there is no problem, but when I try on the server, it can read data but no insert works.

    Security settings are ok, no antivirus on our pre production platform.

    Here is the C# code sample that raise error :

     

        public static void AddNews(News news)
        {
            using (SQLiteConnection connexion = new SQLiteConnection(SqlLiteConnectionString))
            using (SQLiteCommand command = new SQLiteCommand("insert into news (title,date,author,description,encodedtitle) values (@title,@date,@author,@description,@encodedtitle)", connexion))
            {
                command.Parameters.AddWithValue("@title", news.Title);
                command.Parameters.AddWithValue("@date", news.Date);
                command.Parameters.AddWithValue("@author", news.Author);
                command.Parameters.AddWithValue("@description", news.Description);
                command.Parameters.AddWithValue("@encodedtitle", news.EncodedTitle);
                //connexion.Open();
                //command.ExecuteNonQuery(); -----> This causes following error when uncomment this line and above

                using (System.IO.Stream stream = System.IO.File.Open(DatabaseFileName,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite))
                {
                    stream.Close();
                } -----> this works
            }

        }

     

    Error is : 

    • ErrorCode : -2147467259
    • Message : Exception of type 'System.Web.HttpUnhandledException' was thrown.
    • Data : System.Collections.ListDictionaryInternal
    • InnerException : System.Data.SQLite.SQLiteException: Unable to open the database file
      unable to open database file
      at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
      at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
      at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
    Could someone help me to solve the problem ?

     

Page 3 of 3 (37 items) < Previous 1 2 3
Powered by Community Server (Commercial Edition), by Telligent Systems