Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Using LIKE with IF....

Reply
Thread Tools

Using LIKE with IF....

 
 
David
Guest
Posts: n/a
 
      11-03-2004
Hi,

I have a recordset which pulls out specific customer names.
One of our customers have many branches, i.e:
Customer A Site 1
Customer A Site 2
Customer A Site 3
etc.....

I have the following IF statement, and want to catch all of the Customer A names...

If RS("CustomerName") like Customer A * then........

I just want to catch all customer names starting with 'Customer A'.

I'm sure this statement will work, i'm just missing a quote or something ??

Appreciate your help

David
 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      11-03-2004
Why don't you do this IN THE QUERY instead of while processing the results?

You didn't mention what database you're using, but in SQL Server,

SELECT
Customer, site
FROM wherever
WHERE Customer LIKE 'Customer A%'

This reduces the amount of network chatter and lets the engine use an index
instead of returning all the data (often a more expensive table scan).

However, if you insist that you want to do this in ASP, and just throw away
the rest of the rows, then you can't use LIKE. LIKE is a SQL operator, not
present in VBScript.

strLike = "Customer A"
strLen = Len(strLike)
do while not rs.eof
strDB = rs("CustomerName")
if left(lcase(strDB), strLen) = lcase(strLike) then
........
end
rs.movenext
loop

However, I might suggest that your design is flawed, if all 'Customer A%'
are the same customer, then perhaps you should be using a master table and
inserting the ID of the customer instead...

--
http://www.aspfaq.com/
(Reverse address to reply.)




"David" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi,
>
> I have a recordset which pulls out specific customer names.
> One of our customers have many branches, i.e:
> Customer A Site 1
> Customer A Site 2
> Customer A Site 3
> etc.....
>
> I have the following IF statement, and want to catch all of the Customer A

names...
>
> If RS("CustomerName") like Customer A * then........
>
> I just want to catch all customer names starting with 'Customer A'.
>
> I'm sure this statement will work, i'm just missing a quote or something

??
>
> Appreciate your help
>
> David



 
Reply With Quote
 
 
 
 
David Gordon
Guest
Posts: n/a
 
      11-03-2004

Aaron,


Cheers,
that did the trick !

Why did'nt I think of something so simple.....Doh !


Great Work


Thanks again.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
object-like macro used like function-like macro Patrick Kowalzick C++ 5 03-14-2006 03:30 PM
Gmail-like or Orkut-like interface Blmn ASP .Net 0 12-03-2004 01:27 AM
any EL-like MessageFormat-like classes? Ittay Dror Java 1 07-29-2004 05:38 PM
My wife's like kinda what my wife's like { Listerine Enema } Computer Support 0 06-01-2004 01:38 AM
Would like to make a cell look like a dropdown box in the edit mode Alex ASP .Net 0 04-25-2004 09:10 PM



Advertisments