PC Review


Reply
Thread Tools Rate Thread

The char string include #

 
 
Huayang
Guest
Posts: n/a
 
      25th Mar 2007
In access 2000, how to handle the char string including #, like this
equipment name is "1# motor". ths SQL is:

SELECT * FROM Equipment WHERE EquipName LIKE '" & tbEquipName & "*';"

but cann't retrieve equipment data.

Thanks





 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      25th Mar 2007
The trick is to place the wildcard character in square brackets, so Access
treats it as a literal.

This kind of thing:
SELECT *
FROM Equipment
WHERE EquipName LIKE "1[#]motor*";

So, of tblEquipName is a variable that may contain the # character:
SELECT *
FROM Equipment
WHERE EquipName LIKE """" & Replace(tblEquipName,"#","[#]") & "*""";

Of course, if you know exactly what you are looking for, you could just use
= instead of Like:
SELECT *
FROM Equipment
WHERE EquipName = "1#motor";

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Huayang" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In access 2000, how to handle the char string including #, like this
> equipment name is "1# motor". ths SQL is:
>
> SELECT * FROM Equipment WHERE EquipName LIKE '" & tbEquipName & "*';"
>
> but cann't retrieve equipment data.
>
> Thanks


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
string.Replace((char)146, (char)39) does not work? mohaaron Microsoft C# .NET 3 1st Feb 2010 11:05 PM
How to include char & in a string in VB.NET? =?Utf-8?B?ZGF2aWQ=?= Microsoft ASP .NET 4 5th Jan 2006 02:38 AM
How to convert unmanaged string with char array type to managed string with char array type? joye Microsoft VC .NET 1 21st Jul 2005 09:32 AM
System::String, std::string and const char* and newline Vasco Lohrenscheit Microsoft VC .NET 0 13th Jan 2004 03:50 PM
Conversion from managed String to char * or unmanaged char array Jonathan Beck Microsoft VC .NET 0 26th Aug 2003 01:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:52 PM.