jabbaa
asked on
_CtrIsValidHeapPointer(pUserData) problem
I have made a connection to the sql server using ADO within a DLL function. It wokrs fine...
However when I stop my application it prompt an error
File: dbgheap.c
Line: 1011
Expression: _CtrIsValidHeapPointer(pUs erData)
Why should this happen?
I am sure I have close the db connection and set the _RecordSetPrt and _ConnectionPrt to NULL
However when I stop my application it prompt an error
File: dbgheap.c
Line: 1011
Expression: _CtrIsValidHeapPointer(pUs
Why should this happen?
I am sure I have close the db connection and set the _RecordSetPrt and _ConnectionPrt to NULL
can you upload the code in which you create the connection and the code for closing it?
ASKER
The code I am using just as follows:
Thanks
#include <stdio.h>
#include <afxdisp.h>
#import "c:\program files\common files\system\ado\msado15.d ll" rename ("EOF","adoEOF") no_namespace
#define CREATEiNSTANCE(sp,riid) { HRESULT _hr =sp .CreateInstance( __uuidof( riid ) ); \
if (FAILED(_hr)) _com_issue_error(_hr); }
#define RsITEM(rs,x) rs->Fields->Item[_variant_ t(x)]->Val ue
#define UC (char *)
struct InitOle {
InitOle() { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize(); }
} _init_InitOle_; // Global Instance to force load/unload of OLE
void main(){
_RecordsetPtr spRS;
_ConnectionPtr spCON;
try{
CREATEiNSTANCE(spCON,Conne ction);
spCON->ConnectionString = L"driver={sql server};SERVER=(local);Dat abase=pubs ;UID=sa; PWD=;";
// spCON->ConnectionString =L"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=authors.MDB;D efaultDir= C:\\test;" ;
spCON->Open( "", "", "", -1 );
CREATEiNSTANCE(spRS,Record set)
spRS->PutRefActiveConnecti on( spCON );
spRS->Open("select au_lname, au_fname from authors",
vtMissing, adOpenKeyset,
adLockBatchOptimistic, -1
);
while(spRS->adoEOF == false){
printf("au_lname = %s au_fname = %s \n",
UC _bstr_t(RsITEM(spRS,0L)),
UC _bstr_t(RsITEM(spRS,"au_fn ame"))
);
spRS->MoveNext();
}
spRS->Close();
spCON->Close();
}
catch( _com_error &e){
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ")
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ")
+ _bstr_t(e.Description());
MessageBox(0,bs,bstrSource , MB_OK);
}
}
Thanks
#include <stdio.h>
#include <afxdisp.h>
#import "c:\program files\common files\system\ado\msado15.d
#define CREATEiNSTANCE(sp,riid) { HRESULT _hr =sp .CreateInstance( __uuidof( riid ) ); \
if (FAILED(_hr)) _com_issue_error(_hr); }
#define RsITEM(rs,x) rs->Fields->Item[_variant_
#define UC (char *)
struct InitOle {
InitOle() { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize(); }
} _init_InitOle_; // Global Instance to force load/unload of OLE
void main(){
_RecordsetPtr spRS;
_ConnectionPtr spCON;
try{
CREATEiNSTANCE(spCON,Conne
spCON->ConnectionString = L"driver={sql server};SERVER=(local);Dat
// spCON->ConnectionString =L"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=authors.MDB;D
spCON->Open( "", "", "", -1 );
CREATEiNSTANCE(spRS,Record
spRS->PutRefActiveConnecti
spRS->Open("select au_lname, au_fname from authors",
vtMissing, adOpenKeyset,
adLockBatchOptimistic, -1
);
while(spRS->adoEOF == false){
printf("au_lname = %s au_fname = %s \n",
UC _bstr_t(RsITEM(spRS,0L)),
UC _bstr_t(RsITEM(spRS,"au_fn
);
spRS->MoveNext();
}
spRS->Close();
spCON->Close();
}
catch( _com_error &e){
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ")
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ")
+ _bstr_t(e.Description());
MessageBox(0,bs,bstrSource
}
}
look at this page:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt__crtisvalidheappointer.asp
debug your application, and when it's sopt on that line, go back on the stack to see the command and pointer which cause the problem.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt__crtisvalidheappointer.asp
debug your application, and when it's sopt on that line, go back on the stack to see the command and pointer which cause the problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.