Microsoft KB Archive/301534

= BUG: RDO Returns Empty Recordset When You Pass Parameter from Visual Basic to Access =

Article ID: 301534

Article Last Modified on 11/17/2003

-

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.



Steps to Reproduce Behavior
 Create an empty Access database named Db1.mdb in a folder that you intend to use for this test. Create a new table named Table1 that contains the following values:

 Create a new Query named qTable1. Select the Name field from Table1. In the Criteria section for the Name field, type like [Pname] . Save the Query and the database.</li> Create a new Standard EXE project in Visual Basic. Form1 is created by default.</li> From the Project menu, click References, and then select the Microsoft Remote Data Object 2.0 check box.</li> Add a command button to Form1.</li>  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 = &quot;DSN=access&quot; 'Point DSN to Db1.mdb. rdo_db.EstablishConnection rdDriverNoPrompt Set rdo_qd.ActiveConnection = rdo_db rdo_qd.SQL = &quot;{Call qTable1 (?)}&quot; 'Uncomment the following line to resolve this problem. 'rdo_qd.RDOParameters(0).Size = 255 rdo_qd.rdoParameters(0) = &quot;bob&quot; Set rdo_rs = rdo_qd.OpenResultset(rdOpenStatic) If Not rdo_rs.EOF Then MsgBox rdo_rs(0).value Else MsgBox &quot;The Name was not found in the database.&quot; End If   rdo_rs.Close Set rdo_rs = Nothing rdo_qd.Close Set rdo_qd = Nothing </li> Run the application. Notice that you receive the message, &quot;The name was not found in the database.&quot;</li> 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.</li></ol>

Additional query words: RDOParameters

Keywords: kbbug kbnofix kbrdo KB301534

-

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

© Microsoft Corporation. All rights reserved.