new dbwrapper.cpp

Money Manager Ex Development related posts
(http://github.moneymanagerex.org/)

Moderator: Renato

Post Reply
elliswr
MMEX Developer
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX
Contact:

new dbwrapper.cpp

Post 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

madhan
Site Admin
Posts: 99
Joined: Sun Nov 30, 2008 8:06 pm

Re: new dbwrapper.cpp

Post by madhan »

So Without this change, MMEX won't compile under Linux?

Vadim
MMEX Developer
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: new dbwrapper.cpp

Post by Vadim »

I have totally refactored dbwrapper.cpp. I will post my changes soon. Using literals instead of parameters must be prohibited!

Post Reply