Пример #1
0
        internal SqliteBase(SQLitePCL.ISQLiteConnection connection, SqliteDateFormats fmt)
            : base(fmt) {

        }
 internal SqliteConnectionWrapper(SQLitePCL.ISQLiteConnection connection, SqliteDateFormats fmt)
     : base(connection, fmt) 
 {
     if (connection == null) throw new ArgumentNullException("connection");
     _sqliteDbConnection = connection;
 }
 /// <summary>
 /// Initializes the connection with the specified SQLite connection
 /// </summary>
 /// <param name="connection">The SQLite connection to be wrap as an ADO connection</param>
 public SqliteAdoConnection(SQLitePCL.ISQLiteConnection connection) 
     : this(connection, null) { }
        /////<overloads>
        ///// Constructs a new SqliteAdoConnection object
        ///// </overloads>
        ///// <summary>
        ///// Default constructor
        ///// </summary>
        //public SqliteAdoConnection()
        //    : this("") {
        //}

        ///// <summary>
        ///// Initializes the connection with the specified connection string
        ///// </summary>
        ///// <param name="connectionString">The connection string to use on the connection</param>
        //public SqliteAdoConnection(string connectionString) {
        //    _sql = null;
        //    _connectionState = ConnectionState.Closed;
        //    _connectionString = "";
        //    _transactionLevel = 0;
        //    _version = 0;
        //    //_commandList = new List<WeakReference>();

        //    if (connectionString != null)
        //        ConnectionString = connectionString;
        //}

        #endregion

        /// <summary>
        /// Initializes the connection with the specified SQLite connection
        /// </summary>
        /// <param name="connection">The SQLite connection to be wrap as an ADO connection</param>
        /// <param name="cryptEngine">The cryptographic engine to be used for encryption operations</param>
        public SqliteAdoConnection(SQLitePCL.ISQLiteConnection connection, IObjectCryptEngine cryptEngine) {
            if (connection == null) throw new ArgumentNullException("connection");
            _sqliteDbConnection = connection;
            _cryptEngine = cryptEngine;
            _sql = null;
            _connectionState = ConnectionState.Closed;
            _connectionString = "";
            _transactionLevel = 0;
            _version = 0;
            //_commandList = new List<WeakReference>();
        }
Пример #5
0
        /// <summary>
        /// Translates a SQLite result message into a helpful text description (note: creating these helpful text descriptions is currently a work-in-progress).
        /// </summary>
        /// <param name="result">The SQLite result to translate</param>
        /// <returns>Text description</returns>
        public static string ToResultText(SQLitePCL.SQLiteResult result) {
            string resultText = "An unexpected SQLite result was encountered";

            switch (result) {
                case SQLitePCL.SQLiteResult.ABORT:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.AUTH:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.BUSY:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.CANTOPEN:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.CONSTRAINT:
                    resultText = "A SQLite table/column constraint violation occurred.";
                    break;
                case SQLitePCL.SQLiteResult.CORRUPT:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.DONE:
                    resultText = "A SQLite DONE result was returned.";
                    break;
                case SQLitePCL.SQLiteResult.EMPTY:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.ERROR:
                    resultText = "A SQLite ERROR result was returned.";
                    break;
                case SQLitePCL.SQLiteResult.FORMAT:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.FULL:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.INTERNAL:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.INTERRUPT:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.IOERR:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.LOCKED:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.MISMATCH:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.MISUSE:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.NOLFS:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.NOMEM:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.NOTADB:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.NOTFOUND:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.NOTICE:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.OK:
                    resultText = "A SQLite OK result was returned.";
                    break;
                case SQLitePCL.SQLiteResult.PERM:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.PROTOCOL:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.RANGE:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.READONLY:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.ROW:
                    resultText = "A SQLite ROW result was returned.";
                    break;
                case SQLitePCL.SQLiteResult.SCHEMA:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.TOOBIG:
                    resultText += ": " + result.ToString();
                    break;
                case SQLitePCL.SQLiteResult.WARNING:
                    resultText += ": " + result.ToString();
                    break;
                default:
                    resultText += ".";
                    break;
            }

            return resultText;
        }
        /// <summary>
        /// Initializes the statement and attempts to get all information about parameters in the statement
        /// </summary>
        /// <param name="sqlbase">The base SQLite object</param>
        /// <param name="stmt">The statement</param>
        /// <param name="strCommand">The command text for this statement</param>
        /// <param name="previous">The previous command in a multi-statement command</param>
        internal SqliteStatement(SqliteBase sqlbase, SQLitePCL.ISQLiteStatement stmt, string strCommand, SqliteStatement previous) {
            _sql = sqlbase;
            _sqlite_stmt = stmt;
            this._sqlStatement = strCommand;

            // Determine parameters for this statement (if any) and prepare space for them.
            int nCmdStart = 0;
            int n = _sql.Bind_ParamCount(this);
            int x;
            string s;

            if (n > 0) {
                if (previous != null)
                    nCmdStart = previous._unnamedParameters;

                _paramNames = new string[n];
                _paramValues = new SqliteParameter[n];

                for (x = 0; x < n; x++) {
                    s = _sql.Bind_ParamName(this, x + 1);
                    if (String.IsNullOrEmpty(s)) {
                        s = String.Format(CultureInfo.InvariantCulture, ";{0}", nCmdStart);
                        nCmdStart++;
                        _unnamedParameters++;
                    }
                    _paramNames[x] = s;
                    _paramValues[x] = null;
                }
            }
        }