Page 1 of 1

new dbwrapper.cpp

Posted: Thu Sep 03, 2009 2:18 am
by elliswr
Vadim,
I am hoping you can help me out with this one. When I compile with the new dbwrapper, the app hangs on the following line:

Code: Select all

wxString sql = wxString::Format(wxT("insert into CATEGORY_V1 (CATEGNAME) VALUES('%s')"), categoryName);
I don't know why. Should we check to ensure that CATEGORY_V1 exists before inserting anything?

My warning: "cannot pass objects of non-POD type 'const class wxString' through '...'; call will abort at runtime"

[EDIT]: got to looking around and found that GCC apparently has problems with passing a straight wxString and needs a c_str to be passed instead. I found that many other occurrences of sql queries use the .c_str() method. Example:

Code: Select all

wxString bufSQL = wxString::Format(wxT("select * from SETTING_V1 where SETTINGNAME='%s';"), settingName[b].c_str()[/b]);
So I changed

Code: Select all

wxString sql = wxString::Format(wxT("insert into CATEGORY_V1 (CATEGNAME) VALUES('%s')"), categoryName);
to

Code: Select all

wxString sql = wxString::Format(wxT("insert into CATEGORY_V1 (CATEGNAME) VALUES('%s')"), categoryName.[b]c_str()[/b]);
and now all is well.

Thanks Vadim for the new feature. I just wanted to post this here for future reference, and I would move this to Development, but I don't know how.

Cheers,
Wesley

Re: new dbwrapper.cpp

Posted: Sat Sep 05, 2009 3:33 am
by madhan
So Without this change, MMEX won't compile under Linux?

Re: new dbwrapper.cpp

Posted: Mon Sep 07, 2009 7:04 am
by Vadim
I have totally refactored dbwrapper.cpp. I will post my changes soon. Using literals instead of parameters must be prohibited!