Am relatively new to the world of C++. I wish to access the data from a multi-dimensional SAFEARRAY. However when I try to retrieve the value, I get the error 0xC0000005: Access violation reading location 0x40e3e300. Attached below is my code and the marked line is where it errors out. Hopefully someone can shed some light as to how to address it.
SAFEARRAY *ArrayCrosstabInfo = GetMainFrame().m_epsComHelper->GetCrosstab(m_arrayFieldnames,start,end);
COleSafeArray ArrayCrosstab(*ArrayCrosstabInfo,VT_SAFEARRAY);
BSTR *DataValue;
ArrayCrosstab.AccessData((void**) &DataValue);
long lUBoundX;
long lUBoundY;
ArrayCrosstab.GetUBound(1,&lUBoundX);
ArrayCrosstab.GetUBound(2,&lUBoundY);
long lOffset = 2;
int nFieldIndex = 0;
if (lUBoundX > 0 && lUBoundY > 0)
{
//only interested in DataValue[0,x]
for (long i = lOffset; i<=lUBoundY; i++)
{
_bstr_t theData((BSTR)DataValue[0,i],FALSE); <==ERRORS HERE
//Display (BSTR)theData;
}
}