Microsoft KB Archive/245343

= FIX: MDAC 2.1 SP1 Problem Executing Access Query with Wildcard =

Article ID: 245343

Article Last Modified on 4/22/2003

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.1 Service Pack 1
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q245343



SYMPTOMS
In Access the asterisk(*) is the normal wildcard character. However, in Visual Basic with MDAC 2.1 SP1 (version 2.1.1.3711.11(GA)) installed, when calling an Access query using this wildcard character through ADO and the Access ODBC driver, it fails to return any records.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug is corrected in MDAC 2.1 SP2 (2.1.2.4202.3 (GA)), which can be downloaded from here:

http://msdn.microsoft.com/dataaccess



Create the Access Query
In Access 97 or Access 2000, create a query, Query1, with the following SQL statement in the Nwind.mdb or NorthWind.mdb database: Select * From Customers Where Customer ID LIKE 'A*' This should return all of the customer records (4 in all) with a Customer ID that starts with "A".

Visual Basic Test Application
 Start a new project in Visual Basic and choose Standard EXE. Form1 is created by default. Using the Project and References menu, add a reference to the following type library:

Microsoft ActiveX Data Objects 2.1 Library

  Add a Command button (Command1) and the following code to the form: Option Explicit

Private Sub Command1_Click Dim cn As ADODB.Connection, rs As ADODB.Recordset, cmd As ADODB.Command

Set cn = New ADODB.Connection Set cmd = New ADODB.Command Set rs = New ADODB.Recordset

cn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "DBQ=C:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb"

With cmd .Name = "Query1" .CommandText = "Query1" .CommandType = adCmdStoredProc Set .ActiveConnection = cn End With

rs.CursorLocation = adUseClient rs.Open cmd Debug.Print rs.RecordCount

rs.Close cn.Close

End Sub You need to change the path to Nwind.mdb in the connect string to point to the database you modified.  Run the application and click the Command button. On systems with older versions of MDAC 2.1, 0 is returned as the record count. With the later version of MDAC 2.1, the correct number, 4, is returned.

Additional query words: dbado21fix KbGrpMDAC kbGrpVB kbGrpVBDB kbdsupport

Keywords: kbbug kbfix kbmdac250fix kbmdacnosweep KB245343

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.