BUG: RDO Returns Empty Recordset When You Pass Parameter from Visual Basic to Access (301534)



The information in this article applies to:

  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6

This article was previously published under Q301534

SYMPTOMS

An empty recordset is returned when you use Remote Data Objects (RDO) to pass a character type parameter from Microsoft Visual Basic to Microsoft Access.

RESOLUTION

To resolve this problem, set the size of the parameter before you assign a value to the parameter. For example:
    RDO.RDOParameters(0).Size = 255
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create an empty Access database named Db1.mdb in a folder that you intend to use for this test.
  2. Create a new table named Table1 that contains the following values:
    IDName
    1Bob
    2Sue
    3Nancy

  3. Create a new Query named qTable1.
  4. Select the Name field from Table1.
  5. In the Criteria section for the Name field, type like [Pname].
  6. Save the Query and the database.
  7. Create a new Standard EXE project in Visual Basic. Form1 is created by default.
  8. From the Project menu, click References, and then select the Microsoft Remote Data Object 2.0 check box.
  9. Add a command button to Form1.
  10. Copy and paste the following code in the Command click event.
        Dim rdo_db As New rdoConnection
        Dim rdo_rs As rdoResultset
        Dim rdo_qd As New rdoQuery
        
        Set rdo_ws = rdoEngine.rdoEnvironments(0)
        rdo_ws.CursorDriver = rdUseServer
        rdo_db.Connect = "DSN=access" 'Point DSN to Db1.mdb.
        rdo_db.EstablishConnection rdDriverNoPrompt
        Set rdo_qd.ActiveConnection = rdo_db
     
        rdo_qd.SQL = "{Call qTable1 (?)}"
        'Uncomment the following line to resolve this problem.
        'rdo_qd.RDOParameters(0).Size = 255
        rdo_qd.rdoParameters(0) = "bob"  
        Set rdo_rs = rdo_qd.OpenResultset(rdOpenStatic)
        
        If Not rdo_rs.EOF Then
            MsgBox rdo_rs(0).value
        Else
            MsgBox "The Name was not found in the database."
        End If
        
        rdo_rs.Close
        Set rdo_rs = Nothing
        rdo_qd.Close
        Set rdo_qd = Nothing
    					
  11. Run the application. Notice that you receive the message, "The name was not found in the database."
  12. To resolve this problem, uncomment the line for the size of the parameter, and run the application again. Notice that the value for bob is displayed.

Modification Type:MajorLast Reviewed:11/17/2003
Keywords:kbbug kbnofix kbRDO KB301534