My goal is to insert a column into a SQLite Table and then return the entry so that I can get the primary key value. I have the following code that executes generic insert statements for me:
int SQLiteHelper::ExecuteWriteStatement(Platform::String^ statement)
{
char* zErrMsg;
int rc;
LPCWSTR input = statement->Data();
char sql[MAX_PATH + 1];
memset(sql, 0, sizeof(sql));
WideCharToMultiByte(CP_UTF8, 0, input, -1, sql, sizeof(sql), NULL, NULL);
const char* data = "Callback function called";
rc = sqlite3_exec(m_db, sql, WriteCallback, (void*)data, &zErrMsg);
if(rc != SQLITE_OK)
{
OutputDebugString(L"Failed to Write to database");
sqlite3_free(zErrMsg);
}
else
{
OutputDebugString(L"Succesfully wrote to database");
}
}
My callback is implemented as follows (note that it is a static private class method):
int SQLiteHelper::WriteCallback(void *NotUsed, int argc, char** argv, char** azColName)
{
////do some stuff
}
I am aware that I will probably use the void* NotUsed callback parameter to return data and I'm pretty sure it maps to the (void*)data from the sqlite3_exec() function call. The problem I have is that when I run an insert statement, the code does not reach the callback function.
If you run an insert command using sqlite3_exec shouldn't it call the callback method?
Is there a different sqlite command I should be using?
Thanks!