Solved

Using SELECT Like-operator in VBScript

Posted on 1997-10-25
1
507 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
#deleted rowsc access 2010 backend 4 55
Index Details in SQL Server 2012 4 50
How to SQL Trace a SPECIFIC query 24 70
Session that filled up my transaction logs 1 55
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
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…

786 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