Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: Correlation Error Using Parameters.Refresh with SQLOLEDB


View products that this article applies to.

This article was previously published under Q297035

↑ Back to the top


Symptoms

When executing a parameterized UNION query with the SQLOLEDB OLEDB Provider, the following error may be reported:
Run-time error '-2147467259 (80004005)':

The correlation name 'O' is specified multiple times in a FROM clause.

↑ Back to the top


Resolution

To resolve this problem, obtain the latest service pack for SQL Server 2000, the latest service pack for MDAC 2.6, or the hotfix referenced below: For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
290211� INF: How to Obtain the Latest SQL Server 2000 Service Pack
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
300635� INFO: How to Obtain the Latest MDAC 2.6 Service Pack

Hotfix

The English version of this fix should have the following file attributes or later:
 Date        Version         Size      File name     Platform
 -------------------------------------------------------------
 05/17/2001  2000.080.0294   491,584   Sqloledb.dll     x86
 05/17/2001  2000.080.0294    61,440   Sqloledb.rll     x86
				

↑ Back to the top


Workaround

To work around this issue, make sure that the order of the table names in each of the SELECT statements is the same in each UNION query.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in SQL Server 2000 Service Pack 2 and MDAC 2.6 Service Pack 2.

↑ Back to the top


More information

To reproduce this problem, run the following Microsoft Visual Basic code:
Sub CorrelationReproCode()
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim sql As String
Dim fUseOutOfOrderUNION As Boolean

    Set conn = New ADODB.Connection
    conn.Open "Provider=sqloledb;Server=.;Database=northwind;" & _
              "Integrated Security=SSPI;"
    
    ' Change this to False to avoid the problem.
    fUseOutOfOrderUNION = True
    
    If (fUseOutOfOrderUNION) Then
        sql = "SELECT O.OrderDate FROM Customers R, Orders O " & _
              "WHERE R.CustomerId = O.CustomerId AND R.CustomerId = ? " & _
              "Union " & _
              "SELECT O.OrderDate FROM Orders O, Customers R " & _
              "WHERE R.CustomerID = O.CustomerID AND R.Region = ?"
    Else
        sql = "SELECT O.OrderDate FROM Customers R, Orders O " & _
              "WHERE R.CustomerId = O.CustomerId AND R.CustomerId = ? " & _
              "Union " & _
              "SELECT O.OrderDate FROM Customers R, Orders O " & _
              "WHERE R.CustomerID = O.CustomerID AND R.Region = ?"
    End If
    Set cmd = New ADODB.Command
    cmd.CommandText = sql
    Set cmd.ActiveConnection = conn

    ' Error will occur here if fUseOutOfOrderUNION is set to True.
    cmd.Parameters.Refresh
    Set cmd.ActiveConnection = Nothing
    Set cmd = Nothing
    conn.Close
    Set conn = Nothing
    
End Sub
				

↑ Back to the top


Keywords: KB297035, kbsqlserv2000presp2fix, kbmdac260sp2fix, kbfix, kbbug, kbqfe, kbhotfixserver

↑ Back to the top

Article Info
Article ID : 297035
Revision : 5
Created on : 9/26/2005
Published on : 9/26/2005
Exists online : False
Views : 337