Click here to Skip to main content
15,894,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
General_CrtIsValidHeapPointer Pin
Bob Stanneveld24-May-05 4:23
Bob Stanneveld24-May-05 4:23 
GeneralRe: _CrtIsValidHeapPointer Pin
jmkhael24-May-05 6:43
jmkhael24-May-05 6:43 
GeneralRe: _CrtIsValidHeapPointer Pin
Bob Stanneveld25-May-05 21:16
Bob Stanneveld25-May-05 21:16 
GeneralProblem in handling menu :( Pin
nripun24-May-05 4:07
nripun24-May-05 4:07 
QuestionFilmstrip control? Pin
Obliterator24-May-05 2:53
Obliterator24-May-05 2:53 
GeneralDynamic memomory error Pin
evgumin24-May-05 2:26
evgumin24-May-05 2:26 
GeneralRe: Dynamic memomory error Pin
toxcct24-May-05 2:30
toxcct24-May-05 2:30 
GeneralRe: Dynamic memory error Pin
evgumin24-May-05 4:25
evgumin24-May-05 4:25 
There is a peace of code:

void TStationArray::InitCollection()<br />
{<br />
	CMegaBase base;<br />
	CDBVariant** var;<br />
	base.Query.Format("select STATIONNO from STATION order by STATIONNO");<br />
	if ( base.MakeSelectVar("", &var)!=-1 )<br />
	{<br />
		for (int i=0; i<base.n; i++)<br />
		{<br />
			Stationno stno = var[i][0].m_iVal;<br />
			collection.push_back( new TStation(stno) );<br />
			stationnoset.insert(stno);<br />
		}<br />
	}<br />
<br />
	if (var!=NULL)<br />
	{<br />
		for (int i=0; i<base.n; i++)<br />
			delete[] var[i];   //the error appears here<br />
		delete[] var;<br />
	}<br />
	<br />
	UpdateCollection();<br />
}


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)<br />
{<br />
	CDBVariant **v;<br />
	v = NULL;<br />
	CDatabase cdbMyDB;<br />
	CRecordset recSet;<br />
<br />
	if (query=="") query=this->Query;<br />
	<br />
	try<br />
	{<br />
		cdbMyDB.Open(server, FALSE, FALSE, initStr, FALSE);<br />
		if (cdbMyDB.IsOpen ())<br />
		{<br />
			recSet.m_pDatabase=&cdbMyDB;		 <br />
			recSet.Open (CRecordset::snapshot, query, CRecordset::readOnly );<br />
			if (recSet.IsOpen ())<br />
			{<br />
				int i=0,j;<br />
				while (!recSet.IsEOF())<br />
				{<br />
					recSet.MoveNext();<br />
					i++;<br />
				}<br />
				n=i;<br />
				m=recSet.GetODBCFieldCount ();<br />
<br />
				if (n!=0){<br />
					v = new CDBVariant*[n];<br />
				}<br />
				if (!recSet.IsBOF())<br />
				{<br />
					recSet.MoveFirst();<br />
				}<br />
				<br />
				i=0;<br />
				while (!recSet.IsEOF())<br />
				{<br />
					v[i]=new CDBVariant[m];<br />
<br />
					for (j=0; j<m; j++) <br />
					{<br />
						recSet.GetFieldValue (j, v[i][j]);<br />
					}	<br />
					recSet.MoveNext ();<br />
					i++;<br />
				}<br />
			}<br />
			recSet.Close ();<br />
		}<br />
		cdbMyDB.Close ();<br />
	}<br />
	catch (CDBException *err)<br />
	{<br />
		 AfxMessageBox (err->m_strError +recSet.GetSQL ());<br />
		 return -1;<br />
	}<br />
	catch (CMemoryException)<br />
	{<br />
		AfxMessageBox ("memExcept");<br />
	}<br />
<br />
	if (vIn!=NULL) {*vIn=v;}<br />
	pVar=v;<br />
<br />
	return 0;<br />
}



Thanks for your help.
GeneralRe: Dynamic memory error Pin
wb24-May-05 4:41
wb24-May-05 4:41 
GeneralRe: Dynamic memory error Pin
doublebug24-May-05 9:22
doublebug24-May-05 9:22 
GeneralRe: Dynamic memomory error Pin
Cedric Moonen24-May-05 2:56
Cedric Moonen24-May-05 2:56 
GeneralRe: Dynamic memomory error Pin
evgumin24-May-05 4:42
evgumin24-May-05 4:42 
GeneralPopup menu problem ? still need help.. Pin
ddmcr24-May-05 1:56
ddmcr24-May-05 1:56 
GeneralRe: Popup menu problem ??????????? Pin
«_Superman_»24-May-05 3:09
professional«_Superman_»24-May-05 3:09 
GeneralRe: Popup menu problem ??????????? Pin
ddmcr24-May-05 3:14
ddmcr24-May-05 3:14 
GeneralRe: Popup menu problem ? still need help.. Pin
ddmcr24-May-05 6:08
ddmcr24-May-05 6:08 
GeneralPropertySheet tab order problem Pin
Marc Soleda24-May-05 1:24
Marc Soleda24-May-05 1:24 
QuestionWhat this for Pin
rain71124-May-05 0:07
rain71124-May-05 0:07 
AnswerRe: What this for Pin
toxcct24-May-05 0:16
toxcct24-May-05 0:16 
GeneralRe: What this for Pin
rain71124-May-05 2:34
rain71124-May-05 2:34 
GeneralRe: What this for Pin
toxcct24-May-05 2:38
toxcct24-May-05 2:38 
GeneralRe: What this for Pin
rain71124-May-05 4:08
rain71124-May-05 4:08 
GeneralRe: What this for Pin
toxcct24-May-05 4:14
toxcct24-May-05 4:14 
GeneralRe: What this for Pin
rain71124-May-05 4:21
rain71124-May-05 4:21 
GeneralRe: What this for Pin
toxcct24-May-05 4:29
toxcct24-May-05 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.