I use new[] and delete[]. Please, explain what you intended in the second advice. And I represented the code in the answer to toxxct. Thank you.
evgumin
Posts
-
Dynamic memomory error -
Dynamic memomory errorThere is a peace of code:
void TStationArray::InitCollection() { CMegaBase base; CDBVariant** var; base.Query.Format("select STATIONNO from STATION order by STATIONNO"); if ( base.MakeSelectVar("", &var)!=-1 ) { for (int i=0; i This is a static method of the class TStationArray. Memory is occupied in calling base.MakeSelectVar("", &var). I reprsent this method below. `int CMegaBase::MakeSelectVar (CString query, CDBVariant ***vIn) { CDBVariant **v; v = NULL; CDatabase cdbMyDB; CRecordset recSet; if (query=="") query=this->Query; try { cdbMyDB.Open(server, FALSE, FALSE, initStr, FALSE); if (cdbMyDB.IsOpen ()) { recSet.m_pDatabase=&cdbMyDB; recSet.Open (CRecordset::snapshot, query, CRecordset::readOnly ); if (recSet.IsOpen ()) { int i=0,j; while (!recSet.IsEOF()) { recSet.MoveNext(); i++; } n=i; m=recSet.GetODBCFieldCount (); if (n!=0){ v = new CDBVariant*[n]; } if (!recSet.IsBOF()) { recSet.MoveFirst(); } i=0; while (!recSet.IsEOF()) { v[i]=new CDBVariant[m]; for (j=0; jm_strError +recSet.GetSQL ()); return -1; } catch (CMemoryException) { AfxMessageBox ("memExcept"); } if (vIn!=NULL) {*vIn=v;} pVar=v; return 0; }` Thanks for your help.