I have a SQLite DB with one Table : Folder.
when, i try to access it by running this query ("select * from Folder") against the DB, I get an error : SQLITE_DB[4] . I am using the CppSQLite3DB library ( www.codeproject.com/KB/database/CppSQLite.aspx ) .
here is my code :
#include "CppSQLite.h"
try
{
CString sql;
CppSQLite3Query q;
sql.Format(_T("select * from Folder;"));
CppSQLite3DB db;
db.open(DBFile);
CT2CA x(sql); //allows to convert CString to const char*.
const char* st = x;
//CppSQLite3Table tbl = db.getTable("select * from Folder;");
q = db.execQuery(st);
int count = 0;
while(!q.eof())
{
CFolder folder(CString(q.fieldValue(2)));
allFolders.SetAtGrow(count,folder);
q.nextRow();
count++;
}
db.close();
return TRUE;
}
catch(CppSQLite3Exception& e)
{
MessageBox(NULL,CString(e.errorMessage()),_T("Error!"),0);
MessageBox(NULL,_T("An error occured when getting all folders from DB."),CString(e.errorMessage()),0);
}
I noticed CppSQLite3DB::execQuery() calls the function CppSQLite3DB::compile which in turns calls the sqlite function sqlite3_prepare() and that's where the function fails. I think the problem is with sqlite3_prepare.
How do I correct it ?
Thanks.