PRB: ADO Parameter Refresh Error with Access 97 Querydef and Visual Basic
This article was previously published under Q181716 On This PageSYMPTOMS
When using the ADO Parameters.Refresh method with a text datatype parameter
on a parameterized Microsoft Access 97 QueryDef, error 3708 may occur:
The application has improperly defined a Parameter Object.
In version 2.6, the error message is:
Parameter object is improperly defined, inconsistent or incomplete information was provided.
This occurs because a size of zero (0) is returned on the text datatype
parameter by the ADO Refresh method.This article has an example of how to use the ADO Refresh method on a parameterized Microsoft Access 97 QueryDef. Using the Refresh method does result in a round trip to the server so if performance is important, it would be better to create a Parameter collection and define the parameter properties in code. CAUSE
The ADO Parameters.Refresh method does not return the actual parameter Size
property, the method returns a value of 0. Microsoft Access's parameter
syntax does not allow for the size of the parameter to be set in the
QueryDef. Setting the Size property of a text datatype parameter to 0 or a
value less than the actual size of the text field results in an error when
executing the ADO command that passes this parameter.
RESOLUTION
To work around this error it is necessary, in your code, to set the text
datatype parameter .Size property to a value equal to or greater than the
actual field size. The following example shows how to define the Size
property when working with a text datatype parameter. NOTE for ADO 2.1 and later versions: The REFRESH method does NOT return information about the .Name or .Type properties of the Parameters collection as it does in ADO 2.0. Therefore, it is necessary to assign a value to the .Type property. If you need to reference the parameter by name, you also need to assign a value to the .Name property. STATUS
Microsoft is researching this problem and will post new information here in
the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONSteps to Reproduce BehaviorThe following example shows ways to return an ADO recordset from a Microsoft Access QueryDef that expects a parameter to return a recordset of one or more rows. The sample application has two procedures that use Microsoft Access 97 parameterized QueryDefs.The first procedure shows an example of passing a numeric parameter while the second procedure shows an example of passing a text parameter. These two procedures show how using the ADO Parameters.Refresh method retrieves Parameter properties and returns an ADO recordset. NOTE: You will need to acquire and install Microsoft Data Access Components (MDAC) for the sample in this article. The first requirement is to create the Microsoft Access 97 QueryDefs. This article assumes that you are familiar with creating new QueryDefs in Microsoft Access 97. The following Visual Basic code expects two new QueryDefs in the sample Nwind.mdb included with Visual Basic. Create the new QueryDefs with the following properties: Query Name Table Criteria On Field Datatype ------------------------------------------------------------------- ProductsByID Products [ProductID] ProductID Integer CustomerByID Customers [CustomerID] CustomerID TextMake sure you also set the parameter name and datatype in Microsoft Access 97. From the Query menu, choose Parameters. Create each query with three fields. After the Microsoft Access 97 QueryDef's are created, open a new Visual Basic Project. Form1 is created by default.
REFERENCES
For information on creating a Parameter collection for an Access 97
Querydef please see the following article in the Microsoft Knowledge Base:
181782 (http://support.microsoft.com/kb/181782/EN-US/) HOWTO: Work with Access Querydef Parameter Using VB
Microsoft Data Access Components (MDAC) contains ADO, which is needed for this article. For more information on MDAC, please see the following article in the Microsoft Knowledge Base:
175018 (http://support.microsoft.com/kb/175018/EN-US/) HOWTO: Acquire and Install the Microsoft Oracle ODBC Driver
APPLIES TO
| Article Translations
|
Back to the top
