Microsoft KB Archive/194800

= PRB: 'Invalid Use Of Default Parameter' Error in a Recordset DTC =

Article ID: 194800

Article Last Modified on 4/21/2001

-

APPLIES TO


 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q194800



SYMPTOMS
You may use the Data Command Properties dialog box to set the parameters for a parameter query instead of writing the code to use the Data Environment Object directly. After setting the parameters in the Data Command Properties dialog box, you may drag the Data Command from Project Explorer Window and drop it onto your Active Server Page (ASP) to create a Recordset Design-Time Control (DTC). When viewing the page in a browser, you may see the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC SQL Server Driver]Invalid use of default parameter

/textbox_Local/_ScriptLibrary/Recordset.ASP, line 466



CAUSE
When you drag a Data Command from the Project Explorer window and drop it onto an ASP page to create a Recordset DTC, all the values you entered in the Command dialog box are carried over to the Recordset DTC except the Value field. Data Environment uses this value for design-time data binding, and run-time command object execution. When this field is not set during runtime, the above error is generated.



RESOLUTION
Open the Properties dialog box of the Recordset DTC, select Parameters tab, and enter the values you want to use for the parameter. These values should be the same as ones you entered in the Command dialog box.

The parameters can also be set using VBScript on an ASP page and within the  tags of an ASP page prior to the Recordset DTC.

Set the parameters using the setParameter method of the Recordset DTC and open the Recordset. Use this sample snippet when the Automatically open the Recordset is cleared under the Implementation tab of the Recordset Properties dialog box, for example:   <% 'Sets the first parameter Recordset1.setParameter 0, Request.Form("value1")

'Sets the second parameter Recordset1.setParameter 1, Request.Form("value2")

'Open recordset Recordset1.open %>



STATUS
This behavior is by design.



MORE INFORMATION
The values you enter must be the correct data type and size. The values must be able to be evaluated at run time.

If you are using a variable, that variable's value must be set prior to opening the Recordset DTC; alternately, you can use constants or Request objects.

Steps to Reproduce Behavior
 Create a new Project in Visual InterDev 6.0. Add a Data Connection to SQL server sample database "pubs." Add a Data Command using the connection created. Right-click the Data Command to open the Properties dialog box.</li> Click the General tab, type the following SQL statement:

SELECT * FROM authors WHERE (au_id = ?) AND (au_lname = ?)

</li> Click the Parameters tab, most fields should already have been populated.</li> Highlight Param1, enter "value1" in the Value field.</li> Highlight Param2, enter "value2' in the Value field.</li> Add an ASP page to Project.</li> Drag and drop the Data Command to an Active Server Page.</li> View the page</li></ol>

NOTE: Value1 and Value2 should both have been defined.

Keywords: kberrmsg kbprb KB194800

-

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

© Microsoft Corporation. All rights reserved.