« Return to Thread: MySQL example code

mysqlpp::Query Issue

by onlyreply-sql :: Rate this Message:

Reply to Author | View in Thread

Hi All,

I'm not able to reuse mysqlpp::Query  object and program throws exception.  Although,I'm calling    reset() function on it.  Here si the code snippet...



    mysqlpp::Query sqlquery = commonDBCon.query(strquery);
    if (sqlresults = sqlquery.store()) {
            AppDN   = sqlresults[0]["AppDN"];
            AppName = sqlresults[0]["AppName"];
            AppDesc = sqlresults[0]["AppDescription"];
        sqlresults.clear();
        sqlquery.reset();
    }

    // Now, Load Application Step Items
    sprintf(strquery,"select * from ApplicationStepItems where AppDN=%d",nAppDN);
    mysqlpp::Query sqlquery2 = pSystem->m_pCommon->commonDBCon.query(strquery);
    //sqlquery.storein(AppStepItems);
    AppStepItems_Module temp;
    if (sqlresults = sqlquery2.store()) {
        for (size_t i = 0; i < sqlresults.num_rows(); ++i) { 
            //AppStepItems.push_back(sqlresults[i]);
            temp.StepNumber = sqlresults[i]["StepNumber"];
            temp.AppKeypadId = sqlresults[i]["AppKeypadId"];
            temp.NextStepNumber = sqlresults[i]["NextStepNumber"];
            AppStepItems.push_back(temp);
      }
 }


Can anyone please suggest me the solution ? 
My requirements is just to  access multiple tables and store records in appropriate structures/templates.


thanks

 « Return to Thread: MySQL example code

LightInTheBox - Buy quality products at wholesale price!