Solved

Using SELECT Like-operator in VBScript

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

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…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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…

828 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