BUG:Errors When Accessing rdoPreparedStatements Not Consistent

Last reviewed: May 19, 1997
Article ID: Q154810
The information in this article applies to:
  • Enterprise Edition of Microsoft Visual Basic, 32-bit only, for Windows, version 4.0

SYMPTOMS

If you attempt to access a non-existent rdoPreparedStatement, the error you receive depends on whether there are other rdoPreparedStatements in the collection.

If there are none, you will get error:

   40054 - invalid parameter.

If there is at least one, you will get the error:

   40041: Couldn't find object indicated by text.

WORKAROUND

To minimize the impact of this problem, ensure that any error handlers that may trap the above errors perform the same code for both errors.

STATUS

Microsoft has confirmed this to be an issue in the Microsoft products listed at the beginning of this article. Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps To Reproduce Problem

  1. Create a DSN in the 32-Bit ODBC section of the Control Panel. Give it the name "pubs" and configure it to point to the pubs database on a Microsoft SQL server.

  2. Start the 32-bit edition of Visual Basic version 4.0 for Windows. Form1 is created by default.

  3. Add two Command buttons to the form.

  4. Add the following code to the General Declarations section of Form1:

          Option Explicit
    

          Private Sub Command1_Click()
    
            Dim rdocon As rdoConnection
            Dim rdoprep As rdoPreparedStatement
            Set rdocon = rdoEngine(0).OpenConnection("pubs", False, _
                                                     False, "uid=;pwd=;")
            Set rdoprep = rdocon.rdoPreparedStatements("Test1")
          End Sub
    
          Private Sub Command2_Click()
            Dim rdocon As rdoConnection
            Dim rdoprep As rdoPreparedStatement
            Set rdocon = rdoEngine(0).OpenConnection("pubs", False, _
                                                     False, "uid=;pwd=;")
            Set rdoprep = rdocon.CreatePreparedStatement("Test", _
                                                   "Select * from Authors")
            Set rdoprep = rdocon.rdoPreparedStatements("Test1")
          End Sub
    
    

  5. Press the F5 key or click Start on the Run menu to run the application. Click Command1, and you should see that Visual Basic gives the error below: (At this point the prepared statement has not been created.)

          40054 - invalid parameter.
    

  6. Stop Visual Basic by using Stop on the Run Menu. Press the F5 key or click the Run menu again. Click the second button. This time the error will be different as the code has created a prepared statement:

          40041: Couldn't find object indicated by text.
    

REFERENCES

Visual Basic OnLine Help CreatePreparedStatement,rdoPreparedStatements.

Building Client/Server Applications with Visual Basic Manual, Chapter 8.


Keywords : vb432 vb4win kbbuglist
Version : 4.0
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 19, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.