strange errors

Started by
7 comments, last by da_cobra 18 years, 10 months ago
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_piAdoRecordBinding = NULL ;
	
	m_pRS.CreateInstance(__uuidof(Recordset)) ;
	
	try
	{
		m_pRS->Open((LPCTSTR)m_strCmdText,
					(LPCTSTR)m_strConnection,
					adOpenKeyset,
					adLockOptimistic,
					adCmdUnknown) ;
	}
	catch(_com_error &e)
	{
		AfxMessageBox(e.Description()) ;
	}

	if (SUCCEEDED(m_pRS->QueryInterface(__uuidof(IADORecordBinding), (LPVOID*) &m_piAdoRecordBinding)))
	{
		m_piAdoRecordBinding->BindToRecordset(&m_rsADORecSet) ;
		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]
Advertisement
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
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.
Check the HRESULT returned from CreateInstance.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
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 ;}
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]
moe.ron
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 ;} ;
Quote:Original post by da_cobra
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 :

*** Source Snippet Removed ***


Do you call the function like this?

foo->InitDatabase();

My bet is that the value of foo is 0xcdcdcdcd.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
damn you're right!

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

stupid me!!

This topic is closed to new replies.

Advertisement