Solved

Using SELECT Like-operator in VBScript

Posted on 1997-10-25
1
499 Views
Last Modified: 2009-07-29
I'm developing a small search-site in VBScript, where the user is supposed to enter a word or part of a word, and the result should be a list of hits.

But it doesn't seem to work with the Like-operator along with asteriscs (*). Here is an example of a query that doesn't work in ASP, but works fine in Access:

'**********************************
set rs = Server.CreateObject("ADODB.Recordset")

rs.Open "SELECT Glossary.Word, Glossay.Text FROM Glossary WHERE Word Like '" + SearchWord + "') ORDER BY Word", "Data source=Extsn"
'**********************************

The table's name is Glossary. It works fine this way if I don't include any * in SearchWord. If I do, however, I get rs.recordcount to return -1 (I suppose that's alright), and rs.BOF and rs.EOF to return true (that's NOT alright). I can't use any of the rs.Move methods either.

Even if I search for a word that doesn't exists in the database, I get this scenario.

I'm using an MS Access 97 database, along with 32-bit ODBC.

Anyone who recognizes this problem??

0
Comment
Question by:mnp
1 Comment
 
LVL 9

Accepted Solution

by:
cymbolic earned 150 total points
ID: 1025365
Try using the % instead of the *.  While VB takes * as meaning any string, Transact SQL, (used against SQL Server) uses a
% for the same purpose.  There are other special character substitutions between the two as well when using the LIKE clause.  See is this is your problem.


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now