Solved

Using SELECT Like-operator in VBScript

Posted on 1997-10-25
1
511 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

739 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