Ejemplo n.º 1
0
        /// <summary>
        /// Execute statement
        /// </summary>
        /// </param>
        /// <returns>LastResult</returns>
        public int ExecuteStep(   )
        {
            // Execute the statement
            int LastResult = CSSQLite.sqlite3_step(vm);

            return(LastResult);
        }
Ejemplo n.º 2
0
        // private function for reading rows and creating table and columns
        private int ReadNextRow(Vdbe vm, DataTable table)
        {
            int columnCount = table.Columns.Count;

            if (columnCount == 0)
            {
                if ((columnCount = ReadColumnNames(vm, table)) == 0)
                {
                    return(CSSQLite.SQLITE_ERROR);
                }
            }

            int resultType;

            if ((resultType = CSSQLite.sqlite3_step(vm)) == CSSQLite.SQLITE_ROW)
            {
                object[] columnValues = new object[columnCount];

                for (int i = 0; i < columnCount; i++)
                {
                    int columnType = CSSQLite.sqlite3_column_type(vm, i);
                    switch (columnType)
                    {
                    case CSSQLite.SQLITE_INTEGER:
                    {
                        columnValues[i] = CSSQLite.sqlite3_column_int(vm, i);
                        break;
                    }

                    case CSSQLite.SQLITE_FLOAT:
                    {
                        columnValues[i] = CSSQLite.sqlite3_column_double(vm, i);
                        break;
                    }

                    case CSSQLite.SQLITE_TEXT:
                    {
                        columnValues[i] = CSSQLite.sqlite3_column_text(vm, i);
                        break;
                    }

                    case CSSQLite.SQLITE_BLOB:
                    {
                        // Something goes wrong between adding this as a column value and converting to a row value.
                        byte[] encBlob = CSSQLite.sqlite3_column_blob(vm, i);
                        string base64  = Convert.ToBase64String(encBlob);
                        //byte[] decPass = ProtectedData.Unprotect(encBlob, null, DataProtectionScope.CurrentUser);
                        //string password = Encoding.ASCII.GetString(decPass);
                        //columnValues[i] = password;
                        columnValues[i] = base64;

                        break;
                    }

                    default:
                    {
                        columnValues[i] = "";
                        break;
                    }
                    }
                }
                table.Rows.Add(columnValues);
            }
            return(resultType);
        }