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

ID: Q194800


The information in this article applies to:


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 <BODY> 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

  1. Create a new Project in Visual InterDev 6.0.


  2. Add a Data Connection to SQL server sample database "pubs."


  3. Add a Data Command using the connection created.


  4. Right-click the Data Command to open the Properties dialog box.


  5. Click the General tab, type the following SQL statement:
    SELECT * FROM authors WHERE (au_id = ?) AND (au_lname = ?)


  6. Click the Parameters tab, most fields should already have been populated.


  7. Highlight Param1, enter "value1" in the Value field.


  8. Highlight Param2, enter "value2' in the Value field.


  9. Add an ASP page to Project.


  10. Drag and drop the Data Command to an Active Server Page.


  11. View the page


Note: Value1 and Value2 should both have been defined.


Keywords          : kbVisID600 kbGrpASP 
Version           : WINDOWS:6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 5, 1999