Sign in to follow this  
da_cobra

strange errors

Recommended Posts

da_cobra    122
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]

Share this post


Link to post
Share on other sites
JohnBolton    1372
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 this post


Link to post
Share on other sites
da_cobra    122
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 this post


Link to post
Share on other sites
moeron    326
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 this post


Link to post
Share on other sites
da_cobra    122
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 this post


Link to post
Share on other sites
JohnBolton    1372
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this