Parameter query ASSERT
markus@throun.is
Tuesday, August 20, 1996
Environment: MSVC++ 4.2 / (NT 3.51 & W95)
I created a parameter query in Access with one parameter. When opening =
it in Access
I get prompted for the parameter. But using a CDaoRecordset derived =
class with one parameter to access this query doesn't work. I can open =
the underlying table directly,
but not through the parameter query.
I create the query using the following code:
COleVariant varID( "zz" );
CDaoQueryDef MyQuery( pActiveDB );
MyQuery.Open( "" );
MyQuery.SetParamValue( "ID", varID ); // Query criteria is "field =
<> ID"
pMyRecSet->Open( &MyQuery, dbOpenDynaset );
pMyRecSet ->m_nFields =3D MyQuery.GetFieldCount();
pMyRecSet ->m_nParams =3D MyQuery.GetParameterCount();
MyQuery returns 92 fields and 1 parameter which is correct.
When trying to look up records in pMyRecSet using MoveFirst() I get a =
Debug
Assertion Failure in daocore.cpp line 464. MoveFirst() calls Move() =
which in turn calls
GetDataFixupNulls() and there the exception is thrown when performing =
the following
instruction:
void CDaoRecordset::GetDataAndFixupNulls()
{
...
SCODE scode =3D m_pICDAORecordsetGetRows->GetRows(
0, m_nFields, m_prgDaoColBindInfo,
m_cbFixedLengthFields, &m_DaoFetchRows);
// Check for GetRows specific errors
// This is necessary as ICDAORecordset::GetRows
// errors are not appended to DAO errors collection
if (FAILED(scode))
ThrowGetRowsDaoException(scode); // scode=3D-2147024809
...
}
An exception with error code -2147024809 is thrown and I can't figure =
out what it means.
A break occurs as a result in daocore.cpp line 464 when trying to load =
the error text
associated with this error.
----------
Markus Sveinn Markusson, Engineer
Throun Ltd, Hofdabakka 9, IS-112 Reykjavik
Tel. (354) 587-6788, Fax (354) 567-4265
e-mail: markus@throun.is
Jim Leavitt -- jimll@halcyon.com
Saturday, August 24, 1996
Markus:
I created a parameter query in Access with one parameter. When opening =
it in Access
I get prompted for the parameter.=20
If I understand, you've created a CDaoRecordset based on the Access =
query def. That's my preferred method too.
But using a CDaoRecordset derived class with one parameter to access =
this query doesn't work. I can open the underlying table directly, but =
not through the parameter query.
Here's the method I use...
1) Create the dao recordset with class wizard based off your querydef in =
access. It appears you've already done that.
2) Declare a variable of the DaoRecordset... In my case this is a =
COrderSet...
COrderSet theOrders(((CInspectorApp *) AfxGetApp())->m_pDB);
3) Assign values to the parameters... there are three in this recordset
theOrders.m_theCustomer =3D (long) nCustomerNo; 1st parameter
COleDateTime myStartDate(nYear,nMonth,1,0,0,0);
COleDateTime myEndDate(nYear,nMonth,nLastDay,0,0,0);
theOrders.m_StartDate =3D myStartDate; 2nd parameter
theOrders.m_EndDate =3D myEndDate; 3rd parameter
4) Now open the recordset...
if (theOrders.IsOpen())
theOrders.Requery();
else
theOrders.Open();
5) do you stuff. (If you want an exact record count, you have to =
MoveLast and then MoveFirst)
6) Close the recordset if you're done with it.
Jim Leavitt
Mike Blaszczak -- mikeblas@nwlink.com
Tuesday, August 27, 1996
At 11:08 AM 8/20/96 +-100, you wrote:
> // Check for GetRows specific errors
> // This is necessary as ICDAORecordset::GetRows
> // errors are not appended to DAO errors collection
> if (FAILED(scode))
> ThrowGetRowsDaoException(scode); // scode=-2147024809
> ...
>}
>An exception with error code -2147024809 is thrown and I can't figure out
what it means.
>A break occurs as a result in daocore.cpp line 464 when trying to load the
error text
>associated with this error.
Try calling GetErrorMessage() or ReportError() on the exception:
try
{
// do that stuff you were talking about
}
catch (CException* pEx)
{
pEx->ReportError();
pEx->Delete();
}
You'll get actual, real error text in plain language.
.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
| Вернуться в корень Архива
|