Microsoft KB Archive/154810

= FIX: Errors When Accessing rdoPreparedStatements Not Consistent =

Article ID: 154810

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q154810



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 this error:

40054 - invalid parameter.

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

40041: Couldn't find object indicated by text.



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



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

This bug was corrected in Visual Studo 97 Service Pack 3.



Steps To Reproduce Problem
 Create a DSN in the 32-Bit ODBC section of the Control Panel. Name it "pubs" and configure it to point to the pubs database on a Microsoft SQL server. Start the 32-bit edition of Visual Basic version 4.0 for Windows. Form1 is created by default. Add two Command buttons to the form.  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  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 following error: (At this point the prepared statement has not been created.)

40054 - invalid parameter.

 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.

</li></ol>

<div class="references_section">