Microsoft KB Archive/168447

= PRB: DAO SetParamValue Limited to 255 Characters =

Article ID: 168447

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.1 Subscription

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q168447

<div class="symptoms_section">

SYMPTOMS
The execution of a query following a call to CDaoQueryDef::SetParamValue results in an error similar to the following:

<pre class="fixed_text">  DAO Call Failed. m_pDAOQueryDef->Execute(COleVariant((long)nOptions)) In file daocore.cpp on line 2880 scode = 800A0BC9

Error Code = 3017 Source = DAO.QueryDef Description = The size of a field is too long.

<div class="cause_section">

CAUSE
Parameter values are limited to 255 characters.

<div class="resolution_section">

RESOLUTION
Do not call SetParamValue with a value that contains more than 255 characters. If you need to update or insert a record that does contain long data, use a recordset rather than a querydef.

<div class="moreinformation_section">

MORE INFORMATION
DAO and the Jet Engine restrict parameter values to 255 characters or less; this is not a limitation of the MFC DAO classes.

Sample Code
/* Compile options needed: none CDaoDatabase db; CDaoQueryDef query( &db ); int idx; CByteArray blob; const int SIZE = 255;   // Execute will succeed if 255, fail if 256 try {       db.Open( "C:\\DB1.mdb" ); query.Open( "Query1" ); query.SetParamValue( "theID", COleVariant( (long)1, VT_I4 ) );

blob.SetSize( SIZE ); for( idx = 0; idx < SIZE; ++idx ) blob.SetAt( idx, (BYTE)idx ); query.SetParamValue( "theBlob", COleVariant( blob ) ); query.Execute; }   catch( CDaoException* e ) {       AfxMessageBox( e->m_pErrorInfo->m_strDescription,            MB_ICONEXCLAMATION ); e->Delete; }   query.Close; db.Close;

Keywords: kbcode kbdatabase kberrmsg kbprb KB168447

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.