Mono.Data.Sqlite.SqliteException: The database file is locked

I got this error:

Mono.Data.Sqlite.SqliteException: The database file is locked
database is locked
at Mono.Data.Sqlite.SQLite3.Prepare (Mono.Data.Sqlite.SqliteConnection cnn, System.String strSql, Mono.Data.Sqlite.SqliteStatement previous, UInt32 timeoutMS, System.String& strRemain) [0x001e0] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:333
at Mono.Data.Sqlite.SqliteCommand.BuildNextCommand () [0x00019] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteCommand.cs:230

Posts

  • MikeCodesDotNetMikeCodesDotNet GBXamarin Team Xamurai

    This seems to be a standard .Net error rather than something unique to Xamarin.Mac. In that case, you may do well to reach out to the wider .Net community for assistance on this. I would recommend looking at StackOverflow questions of a similar nature.

    To point you in the right direction, you will need to ensure you only have one active connection to the database.

    http://stackoverflow.com/questions/8941944/database-file-is-locked

    http://stackoverflow.com/questions/10139161/sqlite-database-file-was-locked

  • this not work for me.
    My code is following:
    public override void AwakeFromNib()
    {
    try
    {

                ConnectionString = "Data Source=" + ContainerDirectory +"/Library/Application Support/Google/Chrome/Default/History";
                SqliteConnection conn=new SqliteConnection(ConnectionString);
                conn.Open();
                SqliteCommand cmd=new SqliteCommand();
                cmd.Connection=conn;
                cmd.CommandText="select * from urls";
                SqliteDataReader dr=cmd.ExecuteReader();
                while(dr.Read())
                {
                    Console.WriteLine(dr[1].ToString());
                }
    
    
                conn.Close();
            }
    
            catch(Exception e) {
                Console.WriteLine (e);
            }
        }
    
  • When i execute above code then i got this error:
    Mono.Data.Sqlite.SqliteException: The database file is locked database is locked at Mono.Data.Sqlite.SQLite3.Prepare (Mono.Data.Sqlite.SqliteConnection cnn, System.String strSql, Mono.Data.Sqlite.SqliteStatement previous, UInt32 timeoutMS, System.String& strRemain) [0x001e0] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:333 at Mono.Data.Sqlite.SqliteCommand.BuildNextCommand () [0x00019] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteCommand.cs:230

  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    Some other process probably has the database locked.

Sign In or Register to comment.