Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics 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 July 24th, 2006, 09:31 AM
Registered User
 
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jstout62
Default Using the SQL LIKE statement and Wildcards


I am trying to create a parameter query in a table adapter and use the LIKE statement to find data that contains certain text. The SQL command is below:

SELECT ID, UPLOADED, COPIES, MEDIA, COLOR, DUPLEX, ACCOUNT, GROUPNAME, DEVICENAME, FROM jobs_import
WHERE DEVICENAME LIKE ?

This Query only works if the value for the Parameter is exactly what is in the data field. I need to search for partial strings such as in Access where you use a wildcard: LIKE "*HP*" etc.

Anyone know how to do this?

Thanks

js
 
Old July 31st, 2006, 11:16 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Code:
  . . . LIKE '%HP%' . . .
 
Old September 13th, 2006, 08:36 AM
Authorized User
 
Join Date: Nov 2005
Posts: 41
Thanks: 6
Thanked 1 Time in 1 Post
Send a message via MSN to RobCarter
Default

Try passing the text into a variable and using something like "...Like "'*" & varName & "*'"..."

I had the same problem and that worked for me.

Hope it works

Rob Carter





Similar Threads
Thread Thread Starter Forum Replies Last Post
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
SQL Statement??? carswelljr SQL Server 2000 2 August 25th, 2006 12:40 PM
sql statement sand133 VB Databases Basics 2 September 29th, 2004 09:48 AM
Help with SQL statement acdsky SQL Language 3 June 18th, 2004 04:53 AM
T-SQL statement sam78_my SQL Language 1 September 29th, 2003 02:14 AM





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