private void GetNextStatement(IntPtr pzStart, out IntPtr pzTail, out IntPtr pStmt) { if (parent_conn.Version == 3) { SqliteError err = Sqlite.sqlite3_prepare16(parent_conn.Handle, pzStart, -1, out pStmt, out pzTail); if (err != SqliteError.OK) { throw new SqliteSyntaxException(GetError3()); } } else { IntPtr errMsg; SqliteError err = Sqlite.sqlite_compile(parent_conn.Handle, pzStart, out pzTail, out pStmt, out errMsg); if (err != SqliteError.OK) { string msg = "unknown error"; if (errMsg != IntPtr.Zero) { msg = Marshal.PtrToStringAnsi(errMsg); Sqlite.sqliteFree(errMsg); } throw new SqliteSyntaxException(msg); } } }
public void Open() { if (conn_str == null) { throw new InvalidOperationException("No database specified"); } if (state != ConnectionState.Closed) { return; } IntPtr errmsg = IntPtr.Zero; if (Version == 2) { try { sqlite_handle = Sqlite.sqlite_open(db_file, db_mode, out errmsg); if (errmsg != IntPtr.Zero) { string msg = Marshal.PtrToStringAnsi(errmsg); Sqlite.sqliteFree(errmsg); throw new ApplicationException(msg); } } catch (DllNotFoundException) { db_version = 3; } catch (EntryPointNotFoundException) { db_version = 3; } if (busy_timeout != 0) { Sqlite.sqlite_busy_timeout(sqlite_handle, busy_timeout); } } if (Version == 3) { int err = Sqlite.sqlite3_open16(db_file, out sqlite_handle); if (err == (int)SqliteError.ERROR) { throw new ApplicationException(Marshal.PtrToStringUni(Sqlite.sqlite3_errmsg16(sqlite_handle))); } if (busy_timeout != 0) { Sqlite.sqlite3_busy_timeout(sqlite_handle, busy_timeout); } } else { } state = ConnectionState.Open; }