コード例 #1
0
ファイル: Unqlite.cs プロジェクト: yanghuan/unqlite-net
        /// <summary>
        ///  Initializes a new instance of the UnQLite class.
        /// </summary>
        /// <remarks>
        ///  Opening a new database connection.
        ///  If fileName is ":mem:", then a private, in-memory database is created for the connection.
        ///  The in-memory database will vanish when the database connection is closed.Future versions
        ///  of UnQLite might make use of additional special filenames that begin with the ":" character.
        ///  It is recommended that when a database filename actually does begin with a ":" character
        ///  you should prefix the filename with a pathname such as "./" to avoid ambiguity.
        ///  Note: Transactions are not supported for in-memory databases.
        ///  Note: This routine does not open the target database file.
        ///  It merely initialize and prepare the database object handle for later usage.
        /// </remarks>
        /// <param name="fileName">The Operation file.</param>
        /// <param name="model">Control the database access mode.</param>
        /// <exception cref="System.ArgumentNullException">
        ///  fileName is null.
        /// </exception>
        /// <exception cref="UnQLiteException">
        /// The UnQLiteException when open file.
        /// </exception>
        public UnQLite(string fileName, UnQLiteOpenModel model)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            UnQLiteResultCode code = UnsafeNativeMethods.unqlite_open(out pDb_, fileName, model);

            if (code != UnQLiteResultCode.Ok)
            {
                throw new UnQLiteException(code, GetDataBaseErrorLog());
            }
        }
コード例 #2
0
ファイル: Unqlite.cs プロジェクト: yanghuan/unqlite-net
        /// <summary>
        /// Initializes a new instance of the UnQLite class without UnQLiteException.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">
        ///  fileName is null.
        /// </exception>
        public static UnQLiteResultCode TryOpen(string fileName, UnQLiteOpenModel model, out UnQLite unqlite)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            unqlite = null;
            IntPtr            pDB;
            UnQLiteResultCode code = UnsafeNativeMethods.unqlite_open(out pDB, fileName, model);

            if (code == UnQLiteResultCode.Ok)
            {
                unqlite = new UnQLite(pDB);
            }
            return(code);
        }
コード例 #3
0
ファイル: Unqlite.cs プロジェクト: yanghuan/unqlite-net
 public static extern UnQLiteResultCode unqlite_open(out IntPtr ppDB, string zFilename, UnQLiteOpenModel iMode);