Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 202955 - Last Review: May 8, 2003 - Revision: 2.1
PRB: Filter Property Fails When Using Multiple Single Quotation Marks
This article was previously published under Q202955
When you filter a recordset for a character field that contains more than one single quotation mark, for instance CompanyName = O'Riley's Pub, one of the following error messages is displayed:
Run-time Error '3001' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
-or-
Run-time Error '-2147024809 (80070057)': The parameter is incorrect.
For additional information about workarounds for this issue, click the article number below
to view the article in the Microsoft Knowledge Base:
245408Â
(http://kbalertz.com/Feedback.aspx?kbNumber=245408/EN-US/
)
HOWTO: Find a Record Using Complex Criteria with ADO
Steps to Reproduce
- In Microsoft Visual Basic 5.0 or 6.0, open a new Standard EXE project. Form1 is created by default.
- On the Project menu, select References, and add a reference to the Microsoft ActiveX Data Objects 2.x Library.
- Place the following code in the Form1 Code module:
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
With cn
.ConnectionString = "Provider=SqlOledb;Data Source=<server_name>;Initial Catalog=Northwind;User id=<uid>;Password=<pwd>;"
.Open
End With
cn.Execute "update employees set Lastname = 'Davolio''' where EmployeeID = 1"
With rs
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.CursorType = adOpenStatic
.ActiveConnection = cn
.Open "select * from employees"
End With
rs.Filter = "Lastname = 'Davolio'''"
Debug.Print rs.RecordCount
Debug.Print rs(1)
cn.Execute "update employees set Lastname = 'O''Davolio''' where Employeeid = 1"
rs.requery
rs.Filter = "author = 'O''Davolio'''" 'Error Occurs Here
Debug.Print rs.RecordCount
Debug.Print rs(1)
- Run the project. You receive the following error message:
Run-time Error '3001' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
or, under MDAC 2.6, you receive the following error message:
Run-time Error '-2147024809 (80070057)': The parameter is incorrect.
APPLIES TO
- Microsoft Data Access Components 1.5
- Microsoft Data Access Components 2.0
- Microsoft Data Access Components 2.1
- Microsoft Data Access Components 2.1 Service Pack 2
- Microsoft Data Access Components 2.1 Service Pack 1
- Microsoft Data Access Components 2.1 Service Pack 2
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft Data Access Components 2.7
| kbclient kbdatabase kbprb KB202955 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate