473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using LIKE with IF....

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
Jul 21 '05 #1
3 1149
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" <da***@scene-double.co.uk> wrote in message
news:c1**************************@posting.google.c 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

Jul 21 '05 #2
If Aaron's suggestion doesn't work look at InStr()

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"David" <da***@scene-double.co.uk> wrote in message
news:c1**************************@posting.google.c 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

Jul 21 '05 #3

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!
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marshall Mills | last post by:
As I understand it, loaded statement, a using declaration should be all I need to see an enum from within a namespace. The below code works fine with class, struct, and union. What gives? As the...
17
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example ...
14
by: john.burton.email | last post by:
I've done some extensive searching and can't seem to find an answer to this - Is it correct to using "using" with templates, for example: using std::vector; Or do I need to specify the type...
12
by: Calum Grant | last post by:
In older C++ computer books, you'll often see using namespace std; even in my 1996 copy of Stroustrup. Nowadays, it seems to be considered better to qualify names to make it clearer what...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.