Avatar of sqlconsumer
sqlconsumer
Flag for United States of America asked on

SafeArrayGetUBound is returning zero in the lpUbound property ???

Hi,

I'm using ADO to extract data from SQL server. I have an object that runs a stored procedure and returns a recordset successfully.

I'm using GetRows() to populate my SAFEARRAY. I then try to find the Ubound Property using SafeArrayGetUBound and I always retrun zero???

I've not had much experience with SAFEARRAY's does anyone know what I'm doing wrong?


bool SQLStoredProc::GetRows()
{
	if (m_RSPtr == NULL)
		return false;
 
	try {
		m_vArrRows = m_RSPtr->GetRows(ADODB::adGetRowsRest);
 
        HRESULT hr = SafeArrayGetUBound(m_vArrRows.parray, 1,&m_lUbound);
	}
	catch (_com_error e)
	{
		ATLTRACE(_T("Exception thrown: %s\n"), (LPCTSTR)e.Description());
		return false;
	}
 
    return true;
}

Open in new window

C++

Avatar of undefined
Last Comment
sqlconsumer

8/22/2022 - Mon
jkr

Your code looks OK. Any chance that the recordset in question simply is empty?
sqlconsumer

ASKER
The recordset definately has data. If I move through the set using the Next function i return values.

If I look into the parray I can see that it has been populated.

i.e.

m_vArrRows.parray->........cElements = 35473.

Also if I use SafeArrayGetElement() I gets zero's returned.

My recordset is a single column of bits.

let me know if you need any more info
ASKER CERTIFIED SOLUTION
sqlconsumer

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes