dll - c++ sqlite3_prepare_v2 is not working -


this first post excuse me if forget add information, or english mistakes.

i working in c++ code:block(13.12) making dll of sqlite3 functions , using mingw toolchain. (windows 7)

i using sqlite3_exec function want change sqlite3_prepare_v2, sqlite_bind, sqlite3_step, etc because think easy return params. however, after calling new function program written in c++, crash giving me 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 depurated because not use code:block , calling function dll.

this function using, 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 datos 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 ("?") not     if (rc != sqlite_ok) {                 // necessary, recommended         string errmsg(sqlite3_errmsg(db)); // (especially strings) avoid         sqlite3_finalize(stmt);            // formatting problems , 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 calling dll function with:

typedef string (*myfunc5) (sqlite3*,int); myfunc5 mifunc5(0); string string; mifunc5=(myfunc5)getprocaddress(  histdll,"readfromdb"); string=(mifunc5)(db,1); 

an don't think problem db not loaded, because other functions works , tried comment except sqlite3_prepare_v2 , sqlite3_finalize functions, neither works.

edited:

dllsql.h:

#include "sqlite3.h" #include <stdio.h> #include <string> #include <stdexcept>      // std::invalid_argument  /*  use exported function of dll, include header  *  in project.  */       #define dll_export __declspec(dllexport)     using std::string;     using std::exception;               #ifdef __cplusplus         extern "c"         {         #endif           //void dll_export somefunction(const lpcstr sometext);                     int dll_export createdatabase(sqlite3** db,string dbname);                int dll_export ejemplo(char db_err);                int dll_export createtable(sqlite3* db, string tbname,char * db_err);                int dll_export fill(sqlite3* db, string tbname);               void dll_export display(sqlite3* db, string tbname);               void dll_export jokersql(sqlite3* db, string sql);               int dll_export row(sqlite3* db, string tbname,string col,string id,int (*callback)(void*,int,char**,char**),void *answer, char **argv);               int dll_export n_row(sqlite3* db, string tbname,int (*callback)(void*,int,char**,char**),void *answer);                 string dll_export readfromdb(sqlite3* db, int id);           #ifdef __cplusplus         }         #endif 


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -