Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2003, 10:34 AM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADO Find using wildcard on an integer

I have an ado recordset which contain order id's (the field is defined in the database as an integer). In my application, I want to find, for example, the first order id that begins with a 2. When I try to execute the following statement :

rs.find "ID LIKE '2%'"

I get the error:

Find cannot be performed over the specified column, or compare operator is invalid.

I experimented, and it appears that the wildcard does not work on an integer field.

Does anyone know a way around this?

Thanks!!
 
Old June 25th, 2003, 10:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

The LIKE operator only works on character string data. You could define another column in your recordset which CASTs the ID column to a varchar, then use that column in your search expression. E.g:
Code:
SELECT ID, CAST(ID as varchar(10)) as StringID, ...
then use:

rs.find "StringID LIKE '2%'"



Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old June 26th, 2003, 02:14 AM
Registered User
 
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mark.roworth
Default

That is because you are using a string function with an integer. What may work is something like:

rs.Find "CStr(ID) LIKE '2%'"



Mark Roworth





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Find Method of ADO martinaccess Access 3 November 21st, 2007 07:35 AM
Using .Find with ADO phi kyo VB Databases Basics 2 January 16th, 2006 07:11 AM
Find and noMatch ADO knowledge76 Access VBA 1 May 9th, 2005 03:01 PM
ADO Query kills the Wildcard in LIKE stmt Vanaj Access 2 April 1st, 2004 11:31 AM
ADO could ADO counot find the specified provider. Rob Collie Classic ASP Databases 2 June 9th, 2003 04:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.