# strange errors

## Recommended Posts

I get the following error (trying to translate it from dutch to english) : "The instruction at 0x5f4794b6 points to the memory at 0xcdcdcee1. De read or write ("read") on the memory failed." I get the error in the following member function of my class :
HRESULT CAdoDatabase::InitDatabase()
{
::CoInitialize(NULL) ;

m_strConnection = _T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = ..//personen.mdb") ;
m_strCmdText = _T("select * from personen") ;
m_pRS = NULL ;

m_pRS.CreateInstance(__uuidof(Recordset)) ;

try
{
m_pRS->Open((LPCTSTR)m_strCmdText,
(LPCTSTR)m_strConnection,
}
catch(_com_error &e)
{
AfxMessageBox(e.Description()) ;
}

{
return S_OK ;
}
else
{
MessageBox(NULL, "Fout bij het aanspreken van de database!", "Fout!", MB_OK) ;
return S_FALSE ;
}

return S_OK ;
}


If I try to trace the error and I comment stuff out, then from the moment that I pass something to those pointers or strings (@ the top of the code) I get that error. I already did a "rebuild all", by the way (using VC6.0) Hope some1 can help me! TIA [Edited by - da_cobra on May 25, 2005 8:15:46 AM]

##### Share on other sites
A value of 0xcdcdcdcd indicates an uninitialized value in Visual Studio. Apparently, you have a pointer that was initialized from such a value, and you are referencing a location offset 20 bytes from the value of the pointer.

##### Share on other sites
uhm?!? :(

so what do you think I'm doing wrong?
All the member variables in that function are set as private members in my class.

##### Share on other sites
Check the HRESULT returned from CreateInstance.

##### Share on other sites
thx for the reply, but I don't think the error lies there, because if I run the following code, I still get that error :

HRESULT CAdoDatabase::InitDatabase(){	m_strConnection = _T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = ..//personen.mdb") ;	m_strCmdText = _T("select * from personen") ;	m_pRS = NULL ;	m_piAdoRecordBinding = NULL ;		return S_OK ;}

##### Share on other sites
can you tell us what data types those values are? I'm assuming the m_p variables are CComPtrs? What are the m_str variables? _bstr_t ?

That would really help, because you may be assigning the wrong character type into those strings?

[EDIT]
Also if those m_str are BSTR you should use ::SysAllocString and ::SysFreeString
[/EDIT]

##### Share on other sites
sure :

class CAdoDatabase{public :	CAdoDatabase() ;	virtual ~CAdoDatabase() ;private :	CADORecSet			m_rsADORecSet ;	CADORecSet			*m_prsADORecSet ;	_RecordsetPtr		        m_pRS ;	IADORecordBinding	        *m_piAdoRecordBinding ;	CString				m_strConnection ;	CString				m_strCmdText ;} ;

##### Share on other sites
Quote:
 Original post by da_cobrathx for the reply, but I don't think the error lies there, because if I run the following code, I still get that error :*** Source Snippet Removed ***

Do you call the function like this?

foo->InitDatabase();

My bet is that the value of foo is 0xcdcdcdcd.

##### Share on other sites
damn you're right!

I declared the "foo", but didn't initialized it :(

stupid me!!