|
Compile Error/Code Issue: msg#00031db.mysql.c++
After about 2 years of sitting around dreading the idea of doing this on my own, I finally decided to try to get my application functional again by updating to the new code (with lack of C++ experience/much formal training this is a daunting task). After 6.5 hours of trial and error, research galore and pure luck, I've managed to get a 'nearly' functional compile going. I seem to be stuck on a couple of errors which I'm sure are simple and I'm just overlooking something. If someone could lend me a hand and point me in the right direction, or even tell me what I'm doing wrong, I would greatly appreciate it. I've included the errors and coresponding code below. Thank you! ######## Error 1 ######## DatabaseControl.cpp: In constructor 'DatabaseControl::DatabaseControl()': DatabaseControl.cpp:45: error: returning a value from a constructor ####### Code 1 ######### DatabaseControl::DatabaseControl() { // Connect to database server mysqlpp::Connection con(mysqlpp::use_exceptions); try { cout << "Connecting to database server..." << endl; con.connect(DBNAME, DBHOST, DBUSER, DBPASS); } catch (exception& er) { cerr << "Connection failed: " << er.what() << endl; return -1; } ######### Error 2 ######## DatabaseControl.cpp: In member function 'std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Command*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Command*> > > DatabaseControl::getCommands()': DatabaseControl.cpp:69: error: request for member 'query' in '((DatabaseControl*)this)->DatabaseControl::con', which is of non-class type 'Connection*' ######## Code 2 ######## map<string, Command*> DatabaseControl::getCommands() { map<string, Command*> theMap; try { mysqlpp::Query query = con.query(); //Query query = con.query(); //Query query = m_conDB->query(); query << "SELECT * FROM tbl_commands"; mysqlpp::Result res = query.store(); //Result res = query.store(); mysqlpp::Row row; //Row row; mysqlpp::Result::iterator it; //Result::iterator it; for(it = res.begin(); it != res.end(); ++it) { row = *it; Command *newCmd = new Command( row["Name"].get_string(), row["Code"].get_string(), (int)row["MinPosition"], (int)row["Level"], (int)row["Logged"], (int)row["Enabled"] ); theMap[newCmd->getName()] = newCmd; } } catch(const mysqlpp::BadQuery& er) { cerr << "Error querying for Command:" << er.what() << endl; } return theMap; } ########## Error 3 ######### DatabaseControl.cpp: In destructor 'virtual DatabaseControl::~DatabaseControl()': DatabaseControl.cpp:1270: warning: possible problem detected in invocation of delete operator: DatabaseControl.cpp:1270: warning: invalid use of undefined type 'struct Connection' DatabaseControl.h:18: warning: forward declaration of 'struct Connection' DatabaseControl.cpp:1270: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined. ######### Code 3 ########## /** * Destructor for the class. Disconnects from the database and * deletes the pointer to the database connection. */ DatabaseControl::~DatabaseControl() { delete con; //delete m_conDB; con = NULL; //m_conDB = NULL; } -- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-plusplus@xxxxxxxxxxx |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: How to delete a row in mysql++: 00031, Jim Wallace |
|---|---|
| Next by Date: | RE: Compile Error/Code Issue: 00031, Joel Fielder |
| Previous by Thread: | Problems with mysql and mysql++ examplesi: 00031, gary clark |
| Next by Thread: | RE: Compile Error/Code Issue: 00031, Joel Fielder |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |