Microsoft KB Archive/132960

= PRB: Invalid Precision Value Err w/ Character Field Parameters =

Article ID: 132960

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 1.52 Professional Edition

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

 Microsoft Visual C++ 2.1</li></ul>

 Microsoft Visual C++ 2.2</li></ul>

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

 Microsoft Visual C++ 4.1 Subscription</li></ul>

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

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

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

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

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

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

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

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

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

-

<div class="notice_section">

This article was previously published under Q132960

<div class="symptoms_section">

SYMPTOMS
Parameterizing a recordset using one or more character fields may result in an error message similar to the following being returned by an ODBC driver:

<pre class="fixed_text">  Invalid precision value State:S1104,Native:76,Origin:[Microsoft][ODBC dBase Driver]

<div class="cause_section">

CAUSE
If an application does not specify the maximum length of a character field parameter in the recordset's DoFieldExchange function, a default value of 255 is used. Some data sources have a maximum character field length of less than 255.

<div class="resolution_section">

RESOLUTION
To resolve this issue, include a fourth parameter in the RFX_Text function call equal to the size of the character field that is being bound. For example, to bind a parameter to an eight-character field in a database, call the RFX_Text function as follows: pFX->SetFieldType(CFieldExchange::param); RFX_Text(pFX, "FIELD1Param", m_strFIELD1Param, 8);

<div class="moreinformation_section">

MORE INFORMATION
The exception being thrown is generated in the RFX_Text function by the following code: AFX_SQL_SYNC(::SQLBindParameter(pFX->m_hstmt, (UWORD)nField, SQL_PARAM_INPUT, SQL_C_CHAR, (SWORD)nColumnType, nMaxLength, 0, pvParam, 0, plLength)); The ODBC Programmer[ASCII 146]s Reference states the following for the SQLBindParameter S1104 error:

<pre class="fixed_text">  S1104 - Invalid precision value The value specified for the argument cbColDef was outside the range of values supported by the data source for a column of the SQL data type specified by the fSqlType argument.

If no nMaxLength is passed into the RFX_Text, nMaxLength defaults to 255. If the data source does not support text fields of 255, the S1104 error occurs. The Microsoft dBASE and FoxPro drivers, for example, have a maximum character field length of 254. They exhibit the behavior described in this article.

<div class="references_section">