new dbwrapper.cpp

Page 1 of 1
3 posts
new dbwrapper.cpp

elliswr
MMEX Developer

Posts: 151
Joined: Tue May 05, 2009 2:21 am
Location: Granbury, TX
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

madhan
Site Admin

Posts: 242
Joined: Sun Nov 30, 2008 2:06 pm
So Without this change, MMEX won't compile under Linux?
Re: new dbwrapper.cpp

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
I have totally refactored dbwrapper.cpp. I will post my changes soon. Using literals instead of parameters must be prohibited!
Page 1 of 1
Who is online

Users browsing this forum: No registered users and 1 guest

cron