예제 #1
0
    public long LastInsertRowId()
    {
                #if !SQLITE_NATIVE
        if (db == null)
                #else
        if (db == IntPtr.Zero)
                #endif
        {
            throw new Exception("Error database not ready!");
        }

        return(Sqlite3.sqlite3_last_insert_rowid(db));
    }
예제 #2
0
    public void OpenStream(string name, Stream io)
    {
        if (db != null)
        {
            throw new Exception("Error database already open!");
        }

        stream = Sqlite3.sqlite3_stream_create(name, io);

        if (Sqlite3.sqlite3_stream_register(stream) != Sqlite3.SQLITE_OK)
        {
            throw new IOException("Error with opening database with stream " + name + "!");
        }

        if (Sqlite3.sqlite3_open_v2(name, out db, Sqlite3.SQLITE_OPEN_READWRITE, "stream") != Sqlite3.SQLITE_OK)
        {
            db = null;
            throw new IOException("Error with opening database with stream " + name + "!");
        }
    }
예제 #3
0
    public void OpenInMemory()
    {
                #if !SQLITE_NATIVE
        if (db != null)
                #else
        if (db != IntPtr.Zero)
                #endif
        {
            throw new Exception("Error database already open!");
        }

        if (Sqlite3.sqlite3_open(":memory:", out db) != Sqlite3.SQLITE_OK)
        {
                        #if !SQLITE_NATIVE
            db = null;
                        #else
            db = IntPtr.Zero;
                        #endif
            throw new IOException("Error with opening database :memory:!");
        }
    }
예제 #4
0
    public void Open(string filename)
    {
                #if !SQLITE_NATIVE
        if (db != null)
                #else
        if (db != IntPtr.Zero)
                #endif
        {
            throw new Exception("Error database already open!");
        }

        if (Sqlite3.sqlite3_open(filename, out db) != Sqlite3.SQLITE_OK)
        {
                        #if !SQLITE_NATIVE
            db = null;
                        #else
            db = IntPtr.Zero;
                        #endif
            throw new IOException("Error with opening database " + filename + " !");
        }
    }
예제 #5
0
    public void Close()
    {
        ReleaseAllQueries();


                #if !SQLITE_NATIVE
        if (db != null)
        {
            Sqlite3.sqlite3_close(db);
            db = null;
        }

        if (stream != null)
        {
            Sqlite3.sqlite3_stream_unregister(stream);
        }
                #else
        if (db != IntPtr.Zero)
        {
            Sqlite3.sqlite3_close(db);
            db = IntPtr.Zero;
        }
                #endif
    }
예제 #6
0
 public void Rekey(string hexkey)
 {
     Sqlite3.sqlite3_rekey(db, hexkey, hexkey.Length);
 }