this is my first post so excuse me if I forget to add some information, or my english mistakes.
I m working in c++ with code:block(13.12) making a DLL of sqlite3 functions and using MinGW toolchain. (windows 7)
I was using sqlite3_exec function but i want to change to sqlite3_prepare_v2, sqlite_bind.., sqlite3_step, etc because I think it will be easy to get back the return params. However, after calling that new function from another program written also in c++, it crash giving me this error:
Nombre del evento de problema: APPCRASH Nombre de la aplicación: SQL_try.exe Versión de la aplicación: 0.0.0.0 Marca de tiempo de la aplicación: 5594a5af Nombre del módulo con errores: sqlite3.dll Versión del módulo con errores: 3.8.10.2 Marca de tiempo del módulo con errores: 555cd28a Código de excepción: c0000005 Desplazamiento de excepción: 0001ee21 Versión del sistema operativo: 6.1.7601.2.1.0.768.3 Id. de configuración regional: 3082 Información adicional 1: 0a9e Información adicional 2: 0a9e372d3b4ad19135b953a78882e789` Información adicional 3: 0a9e Información adicional 4: 0a9e372d3b4ad19135b953a78882e789
I can not easily depurated it because I m not use to code:block and also I m calling the function from a DLL.
This is the function I m using, that i get it from this other post:[Proper use of callback function of sqlite3 in C++
string DLL_EXPORT readFromDB(sqlite3* db, int id)
{ string result;
sqlite3_stmt *stmt;
const char *sql="SELECT name FROM datos WHERE id = ?";
int rc = sqlite3_prepare_v2(db, sql,-1 , &stmt, NULL);
if (rc != SQLITE_OK)
return string(sqlite3_errmsg(db));
rc = sqlite3_bind_int(stmt, 1, id); // Using parameters ("?") is not
if (rc != SQLITE_OK) { // really necessary, but recommended
string errmsg(sqlite3_errmsg(db)); // (especially for strings) to avoid
sqlite3_finalize(stmt); // formatting problems and SQL
return errmsg; // injection attacks.
}
rc = sqlite3_step(stmt);
if (rc != SQLITE_ROW && rc != SQLITE_DONE) {
string errmsg(sqlite3_errmsg(db));
sqlite3_finalize(stmt);
return errmsg;
}
if (rc == SQLITE_DONE) {
sqlite3_finalize(stmt);
return string("customer not found");
}
result= string((char *)sqlite3_column_text(stmt, 0))+ " ";
// *result=*result + string((char*)sqlite3_column_text(stmt, 1)) +" ";
//*result=*result + string((char*)sqlite3_column_int(stmt, 2));
sqlite3_finalize(stmt);
return result;
}
I m calling the DLL function with:
mifunc5=(Myfunc5)GetProcAddress( histDLL,"readFromDB");
aString=(mifunc5)(db,1);
An I don't think that the problem is that the db is not loaded, beacuse the other functions works and i tryed to comment all except the sqlite3_prepare_v2 and sqlite3_finalize funtions, neither works.
Thank you very much for your attention. :)
Aucun commentaire:
Enregistrer un commentaire