List:MySQL++« Previous MessageNext Message »
From:<webmaster Date:October 23 2006 1:33pm
Subject:MySQL++ crash on << and more
View as plain text  
Hey all
Ive got the following code, the comments show whats wrong with it


ofstream ofin;
ofin.open("log.log");
if (!con.connect("database", "host", "username", "password", 3306))
{
    return;
}
if (!con.select_db("teamin_fate"))

{
return;
}

mysqlpp::Query query = con.query();

// Following crashes the application
//query << "SELECT * FROM news";
//query.execute();

// following 2 methods work, but cause error:
// Commands out of sync; you cant run this command now
query.execute("SELECT * FROM news");


//std::string sql = "SELECT * FROM news";
//query.exec(sql);


mysqlpp::Result res = query.store();

if (res)
{
    //code
}
else
{
    ofin << query.error();
}

What comes out is the error Commands out of sync. res must be null in order to write stuff
to the file. Ive checked where exactly the error occures and it is at the following line:
mysqlpp::Result res = query.store();

Ive also debugged and see what went wrong but I couldn't figure it out. The variable res
is not null, or shouldn't be, because there are various values set according to the
debugging information. So two questions here: Why is the << operator not working
and why is it causing the error I described?

Thanks

Thread
MySQL++ crash on << and morewebmaster23 Oct
  • Re: MySQL++ crash on << and moreWarren Young23 Oct
Re: MySQL++ crash on << and morewebmaster23 Oct
  • Re: MySQL++ crash on << and moreDrew M.23 Oct
  • Re: MySQL++ crash on << and moreWarren Young23 Oct
Re: MySQL++ crash on << and morewebmaster24 Oct
Re: MySQL++ crash on << and morewebmaster24 Oct