Help and Support
 

powered byLive Search

FIX: ADO Suppresses Errors When Fetching into Nonvariant Datatypes

Article ID:274423
Last Review:September 26, 2005
Revision:2.1
This article was previously published under Q274423
On This Page

SYMPTOMS

When fetching rowset values into nonvariant datatypes, ActiveX Data Objects (ADO) may suppress errors that are related to the status of the recordset, such as notifications that the record is locked by another user.

This problem occurs in Microsoft Data Access Components (MDAC) version 2.50.4403.12 (Microsoft Windows 2000/MDAC 2.5 RTM) and 2.51.5303.5 (Windows 2000/MDAC 2.5 SP1). This problem does not occur in MDAC version 2.60.6526.3 (MDAC 2.6 RTM).

Back to the top

CAUSE

A slightly different code path is taken depending on whether the application is fetching into variant datatypes. The use of variants is wrapped in an internal context object which has the ability to return error information. Nonvariants do not have this context wrapper and do not return error information.

Back to the top

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft Data Access Components 2.5. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
293312 (http://support.microsoft.com/kb/293312/) INFO: How to Obtain the Latest MDAC 2.5 Service Pack
The English version of this has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date       Version        Size             File name
   ----------------------------------------------------------
   8/29/2000  2.51.5629.0     20,480 bytes    Msader15.dll
   8/29/2000  2.51.5629.0    487,696 bytes    Msado15.dll
   8/29/2000  2.51.5629.0    172,304 bytes    Msadomd.dll
   8/29/2000  2.51.5629.0     57,616 bytes    Msador15.dll
   8/29/2000  2.51.5629.0    184,592 bytes    Msadox.dll
   8/29/2000  2.51.5629.0     57,616 bytes    Msadrh15.dll
   8/29/2000  2.51.5629.0     94,480 bytes    Msjro.dll
				

Back to the top

WORKAROUND

There is no workaround for this issue.

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 Microsoft Data Access Components 2.5 Service Pack 2.

Back to the top

MORE INFORMATION

Steps to Reproduce Behavior

1.Copy the following code into a Visual Basic project:

Note You must change the UID <username> value and the PWD =<strong password> value to the correct values before you run this code. Make sure that UID has the appropriate permissions to perform this operation on the database.
Dim cn As ADODB.Connection, cnOtherUser As ADODB.Connection
Dim rs As ADODB.Recordset, rsOtherUser As ADODB.Recordset
Dim strConn As String, strSQL As String
Dim varData As Variant, intData As Integer

strConn = "Provider=MSDASQL;Driver={SQL Server};Server=YourServer;Database=Northwind;UID=<user name>;PWD=<strong password>;"
strSQL = "SELECT * FROM Customers"

Set cnOtherUser = New ADODB.Connection
cnOtherUser.Open strConn
Set rsOtherUser = New ADODB.Recordset
rsOtherUser.Open strSQL, cnOtherUser, adOpenKeyset, adLockPessimistic, adCmdText
rsOtherUser.MoveFirst

Set cn = New ADODB.Connection
cn.Open strConn
cn.CommandTimeout = 10
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenKeyset, adLockPessimistic, adCmdText
If MsgBox("Use Variant?", vbYesNo) = vbYes Then
    On Error Resume Next
    varData = rs(0)
    If Err.Number <> 0 Then
        MsgBox Err.Description
        Err.Clear
        cn.Errors.Clear
    Else
        MsgBox "No error!"
    End If
    On Error GoTo 0
Else
    On Error Resume Next
    intData = rs(0)
    If Err.Number <> 0 Then
        MsgBox Err.Description
        Err.Clear
        cn.Errors.Clear
    Else
        MsgBox "No error!"
    End If
    On Error GoTo 0
End If
rs.Close
cn.Close

rsOtherUser.Close
cnOtherUser.Close
					
2.Add a reference to the Microsoft ActiveX Data Objects 2.5 Library.
3.Run the code, and choose Yes when prompted to use a Variant. Note that a "Timeout expired" error message is returned, indicating that the records could not be fetched in the specified amount of time.
4.Run the code again, and this time choose No when prompted to use a Variant. This time an error is returned stating that there is no current record, but there is no indication that you exceeded your timeout.

Back to the top

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
247757 (http://support.microsoft.com/kb/247757/EN-US/) FIX: Connection Leak Using Parameterized Command In ADO
264442 (http://support.microsoft.com/kb/264442/EN-US/) FIX: ADO Recordset Loses Filter Property When Marshalled In-Proc
264701 (http://support.microsoft.com/kb/264701/EN-US/) FIX: Passing ADO Recordset ByRef Resets Error Information

Back to the top


APPLIES TO
Microsoft ActiveX Data Objects 2.5
Microsoft Data Access Components 2.5
Microsoft Data Access Components 2.5 Service Pack 1

Back to the top

Keywords: 
kbbug kbfix kbmdac250fix kbqfe kbado250fix kbhotfixserver KB274423

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.