Code: Select all
int GLOBAL::SaveAnalysis(cAnalysis* analysis)
{
if (!analysis) return 0;
wxString cmd = wxT("insert into analysis (id, name, analysis, care, customerid, delivery) values (");
cmd << analysis -> GetId() << wxT(", ");
cmd << analysis -> Get(ANALYSIS_FIELDS_NAME) << wxT(", ");
cmd << analysis -> Get(ANALYSIS_FIELDS_ANALYSIS) << wxT(", ");
cmd << analysis -> Get(ANALYSIS_FIELDS_CARE) << wxT(", ");
cmd << analysis -> Get(ANALYSIS_FIELDS_CUSTOMER) << wxT(", ");
cmd << analysis -> Get(ANALYSIS_FIELDS_DELIVERY) << wxT(");");
int t = 0;
try
{
t = mainDB -> ExecuteUpdate(cmd);
}
catch (wxSQLite3Exception& e)
{
wxMessageBox(wxString(wxT("ERRORE DURANTE IL SALVATAGGIO NEL DATABASE\n")) << cmd << wxT("\n") << e.GetErrorCode() << wxT(": ") << e.GetMessage(), wxT("ERRORE"), wxICON_ERROR);
}
return t;
}
The code work but the query don't go and this is the output:
ERRORE DURANTE IL SALVATAGGIO NEL DATABASE
insert into analysis(id, name, analysis, care, customerid, delivery) values (0, test, analisi, cura, 0, consegna);
1: SQL logic error or missing database[1]: no such column: test
This is the creation:
Code: Select all
try
{
wxSQLite3Database::InitializeSQLite();
GLOBAL::mainDB = new wxSQLite3Database();
MAIN_DB -> Open(GLOBAL::mainPATH);
if (!MAIN_DB -> TableExists(wxT("preferences")))
MAIN_DB -> ExecuteUpdate(wxT("create table preferences(field char(20), value char(20));"));
if (!MAIN_DB -> TableExists(wxT("analysis")))
MAIN_DB -> ExecuteUpdate(wxT("create table analysis(id int primary key, name char(30), analysis text, care text, customerid int, delivery text);"));
if (!MAIN_DB -> TableExists(wxT("customer")))
MAIN_DB -> ExecuteUpdate(wxT("create table customer(id int primary key, fullname char(30), addres char(100), fiscalcode char(20), mail char(30));"));
}
catch (wxSQLite3Exception& e)
{
wxMessageBox(wxString(wxT("ERRORE NELL'INIZIALIZZAZIONE DEL DATABASE\n")) << e.GetErrorCode() << wxT(": ") << e.GetMessage(), wxT("ERRORE"), wxICON_ERROR);
}