SQLite Forum

QT Framework and SQLite SEE
Login
So I am implementing an encrypted database with SEE and QT Framework.

I have been trying to create the database and then open it and apply the key but when I do a query, I get the message "file is not a database" and I also get the error 26 returned.

I have done the following to initialize and create the database.

Create
1) call sqlite3_activate_see
2) call sqlite3_open_v2
3) call dbReturn = sqlite3_rekey(_pdb,key,-1);
on success I close the database then open it again.
I do this to inititialize it with the key method.

4)  call sqlite3_open_v2
5)  dbReturn = sqlite3_key(_pdb,key,-1);
So now my database should be created and have no tables in it. 
It should also be encrypted but usable.

6) Create table and insert one record to read it.
7) query the table for the record
   QString  sql = "SELECT * from MyDataTable where Id=1;"
   sqlite3_stmt *stmt;
   int rc = sqlite3_prepare_v2(_pdb, query.toUtf8().constData(), -1, &stmt,NULL);
   if (rc != SQLITE_OK)
   {
       return false;
   }
   while ((rc = sqlite3_step(stmt)) == SQLITE_ROW)
   {
      switch (sqlite3_column_type(stmt, i))
      {
     case SQLITE_TEXT:
     {
         char *pMyData16  = (char*)  sqlite3_column_text16 (stmt, i);
         int myBytes = sqlite3_column_bytes(stmt, i);
         char myData16[myBytes + 1];
         memcpy(myData16,pMyData16, myBytes );
         result.ColumnText16 = myData16;

         char *pMyData  = (char*)  sqlite3_column_text (stmt, i);
         myBytes = sqlite3_column_bytes(stmt, i);
         char myData[myBytes + 1];
         memcpy(myData,pMyData, myBytes );
         result.ColumnText = myData;
         break;
     }
}
...
My problem is that when I call the sqlite3_column_text function, I get garbage back. 
Not sure how to solve this.