We help IT Professionals succeed at work.

How to locate a string containing a euro-sign €

Stef Merlijn
Stef Merlijn asked
on
362 Views
Last Modified: 2012-05-11
Hi,

I'm trying to locate a string in a table.
MyString := 'Test € 50';
Query1.Locate('Name', MyString,[]);

This doesn't find the record even though it exists.
Is there any other way to do this?
Comment
Watch Question

Commented:
Query1.Filtered := False;
Query1.Filter := 'Name = ' + QuotedStr(MyString);
Query1.Filtered := True;

check Query1.RecordCount > 0...

But your code should work...
check your sql...
CERTIFIED EXPERT
Top Expert 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Stef MerlijnDeveloper

Author

Commented:
This works just fine. Thank you
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009

Commented:
What database type is it ?
And what character set does it use.

For instance if it's oracle and your character set is ISO8859CP1,
it can look like it is in the database, but it's not actually there ... :)
The iso charset does not contain the Euro symbol (ASCII 120)

If this is the case, the databasecharacterset must be changed to WE8MSWIN1252
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009

Commented:
jymiX ... parameters ... parameters ... parameters  ?
In some SQL versions, it's
Select Name from Table1 where Name = '%€%'

So, in Delphi:
Query1.SQL.Text := 'Select Name from Table1 where Name like '''%€%''';
 
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009

Commented:
use parameters !
it wil get correctly translated

Query1.SQL.TExt := 'SELECT NAME FROM TABLE1 WHERE NAME LIKE :PARAM';
Query1.ParamByName('PARAM').AsString := '%€%';
Query1.Open;
Stef MerlijnDeveloper

Author

Commented:
Yes the parameter-part needs to be added to the SQL.
And I needed an exact search (so without %%).

Thank you all for the other suggestions.
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009

Commented:
if you can't find your record, first use the %%, next starting narrowing your search

check case sensitivity

where upper(name) like :param

ParamByName('PARAM').AsString := UpperCase('SearchString');
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.