Knowledge Base

ADO Find method only supports one criteria

Article ID: 195222

Article Last Modified on 7/6/2006


APPLIES TO


This article was previously published under Q195222

SYMPTOMS

When you attempt to use the ActiveX Data Objects (ADO) Find method to search by multiple criteria, or in other words you use AND, the following error occurs:
Error: 3001:
This application is using arguments that are of the wrong type, out of acceptable range or in conflict with one another.

CAUSE

The Find method is a single column operation only because the OLE DB specification defines IRowsetFind this way.

The ADO 2.5 and later documentation for the Find method (ADO) explains in the Remarks section of the Help Topic:

Only a single-column name may be specified in criteria. This method does not support multi-column searches.

RESOLUTION

This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
Here are four possible workarounds to this limitation. The limitations of this Multi-Find method versus the ADO Find method are that it does not support the "SkipRows", "SearchDirection", or "Start" parameters. If you want these features, you need to create a more complicated custom multi-find method. The Multi-Find method would have to parse the criteria string out properly, navigate the recordset accordingly while checking each criteria for matches.

STATUS

This behavior is by design.

MORE INFORMATION

The ADO Help documentation states the following for the Find method's first argument, criteria:

A String containing a statement that specifies the column name, comparison operator, and value to use in the search.

Steps to Reproduce Behavior

  1. Start Microsoft Visual Basic, Form1 is created by default.
  2. Set a Project Reference to the Microsoft ActiveX Data Objects Library.
  3. Insert a command button on the form.
  4. Insert the following code into the Command1_Click event:
          Dim objConnection As New ADODB.Connection
          Dim rs As New ADODB.Recordset
    
          objConnection.ConnectionString = _
          "Provider=SQLOLEDB;Data Source=<server>;" & _
          "User ID=<uid>;Password=<pwd>;" & _
          "Initial Catalog=Northwind"
          objConnection.Open
    
          rs.Open "Select * from customers", objConnection, _
          adOpenStatic, adLockOptimistic
          rs.Find "Customerid = 1 and companyname = 'Hello'"
    					
  5. Run the form and click the command button. RESULTS: The error occurs.

REFERENCES

For additional information, please search the MSDN Library for the topic Find method (ADO). For additional information, please see the following article in the Microsoft Knowledge Base:

193871 INFO: Passing ADO Recordsets in Visual Basic Procedures

Keywords: kbdatabase kbprb KB195222