Solved

Using SELECT Like-operator in VBScript

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

In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…

947 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

19 Experts available now in Live!

Get 1:1 Help Now