PRB: ADO Parameters.Refresh Fails with MSDAORA Provider and Parameterized Query (240205)



The information in this article applies to:

  • Microsoft OLE DB Provider for Oracle 2.0
  • Microsoft OLE DB Provider for Oracle 2.1
  • Microsoft OLE DB Provider for Oracle 2.5
  • Microsoft OLE DB Provider for Oracle 2.6
  • Microsoft OLE DB Provider for Oracle 2.7

This article was previously published under Q240205

SYMPTOMS

When you use ActiveX Data Objects (ADO), you can call the Parameters.Refresh method for a parameterized SELECT statement. When you are using the Microsoft OLE DB Provider for Oracle (MSDAORA), this may return the following error:
The Provider cannot derive parameter info and SetParameterInfo has not been called.
The HRESULT error code is DB_E_PARAMUNAVAILABLE (0x80040e51).

CAUSE

The Microsoft OLE DB Provider for Oracle does not derive parameter information.

RESOLUTION

If you need this functionality, use the OLE DB Provider for ODBC and the Microsoft Oracle ODBC driver.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Microsoft Visual Basic 6.0, create a new project.
  2. Add a reference to the ADO library.
  3. Add two buttons to run the two routines provided below. One routine calls to the OLE DB Provider for Oracle, and the other calls to the ODBC driver by way of the ODBC OLE DB Provider. The OLE DB routine returns the error shown in the "Symptoms" section, and the ODBC routine works correctly.
    Private Sub cmdUseOLEDB_Click()
        Dim cnDatabase As ADODB.Connection
        Dim qryParameterized As ADODB.Command
        Dim strConn As String
        Dim strSQL As String
        
        strConn = "Provider=MSDAORA;Data Source=myOracleSrv;" & _
                  "User ID=demo;Password=demo;"
        strSQL = "SELECT * FROM Customer WHERE CUSTID = ?"
        
        Set cnDatabase = New ADODB.Connection
        cnDatabase.Open strConn
        
        Set qryParameterized = New ADODB.Command
        Set qryParameterized.ActiveConnection = cnDatabase
        qryParameterized.CommandText = strSQL
        qryParameterized.CommandType = adCmdText
        qryParameterized.Parameters.Refresh
        MsgBox qryParameterized.Parameters.Count
        Set qryParameterized = Nothing
        cnDatabase.Close
        Set cnDatabase = Nothing
    End Sub
    
    Private Sub cmdUseODBC_Click()
        Dim cnDatabase As ADODB.Connection
        Dim qryParameterized As ADODB.Command
        Dim strConn As String
        Dim strSQL As String
        
        strConn = "Provider=MSDASQL;Driver={Microsoft ODBC for Oracle};" & _
                  "Server=myOracleSrv;UID=demo;PWD=demo;"
        strSQL = "SELECT * FROM Customer WHERE CUSTID = ?"
        
        Set cnDatabase = New ADODB.Connection
        cnDatabase.Open strConn
        
        Set qryParameterized = New ADODB.Command
        Set qryParameterized.ActiveConnection = cnDatabase
        qryParameterized.CommandText = strSQL
        qryParameterized.CommandType = adCmdText
        qryParameterized.Parameters.Refresh
        MsgBox qryParameterized.Parameters.Count
        Set qryParameterized = Nothing
        cnDatabase.Close
        Set cnDatabase = Nothing
    End Sub
    					
  4. Substitute your Oracle server database alias for the one that is used in the sample (Server=myOracleSrv and Data Source = myOracleSrv).

Modification Type:MajorLast Reviewed:9/30/2003
Keywords:kbDatabase kbOracle kbprb kbProvider KB240205