sqlite3 integration

Hello I have this code but can’t open database:

int result;
sqlite3 db = NULL;
std::string sqlstr;
CCFileUtils
fileUtils = CCFileUtils::sharedFileUtils();
std::string writablePath = fileUtils->getWritablePath();
const char *fileName =“hpc_db.sqlite”;
writablePath.append(fileName);

CCLog(“%s”, writablePath.c_str());

result = sqlite3_open(writablePath.c_str(),&db);
if( result != SQLITE_OK )
{
CCLog(“DB Opened”);
}
else
{
CCLog(“OPENING WRONG”);;
}

sqlite3_close(db);

I think the problem is I didn’t write db file to writablepath. Can someone share some code on how to do that?

I think “hpc_db.sqlite” should be “hpc_db.db”,
You try again.

I found the issue.

if( result != SQLITE_OK )

should be:

if( result == SQLITE_OK )

So silly!

I recommend the CppSQLite(C++ Wrapper for SQLite) for you.I’m using it,very good!
Google it.or click http://www.codeproject.com/Articles/6343/CppSQLite-C-Wrapper-for-SQLite