jeudi 26 août 2021

copy record set in local _RecordsetPtr in C++

kindly provide suggestion, I am have getResults function and executing a query in C++.

int ABC::getResult(char *query)
{
    _CommandPtr     pCom;
    _bstr_t         lv_query;
    lv_query        = (_bstr_t) sqlQuery;

    try
    {
        pCom.CreateInstance(__uuidof(Command));
        pCom->ActiveConnection = pConn;
        pCom->CommandType = adCmdText;
        pCom->CommandText = lv_query;
        pCom->CommandTimeout = 60;
        RecordSet = pCom->Execute(NULL, NULL, adCmdText);       
    
    }
    catch(_com_error &e)
    {
        _bstr_t bstrSource(e.Source());
        _bstr_t bstrDescription(e.Description());
        sprintf_s(errStr,sizeof(errStr), "Exception:Failed to get detail from database.");
        
        return ERR_EXCEPPTION;
    }

now I have to copy the _RecordsetPtr RecordSet of this funtion which is a public member of ABD class.

I am doing like below:

ABC class will make the connection to Database.

    ABC mConnect;
    
    mConnect.getResults(query);
    
    _RecordsetPtr lv_set = std::move(mConnect.RecordSet);

    mConnect.CloseConnection();

Above std::move is not working , and I get lv_set as null; I want to achieve that once I take recordset in local copy , I want to close the DB connection and proceed with local recordset to fetch the results Is there any way to achieve it.

Aucun commentaire:

Enregistrer un commentaire