• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

How to locate a string containing a euro-sign €

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?
0
Stef Merlijn
Asked:
Stef Merlijn
1 Solution
 
fromerCommented:
Query1.Filtered := False;
Query1.Filter := 'Name = ' + QuotedStr(MyString);
Query1.Filtered := True;

check Query1.RecordCount > 0...

But your code should work...
check your sql...
0
 
jimyXCommented:
Use SQL query.
To find exact match:
MyString := 'Test € 50';
Query1.SQL.Text := 'Select Name from Table1 where Name = '+QuotedStr(MyString);
Query1.Open;

To find all records that contain the euro-sign:
MyString := '€';
Query1.SQL.Text := 'Select Name from Table1 where Name like '+QuotedStr(MyString);
Query1.Open;
0
 
Stef MerlijnDeveloperAuthor Commented:
This works just fine. Thank you
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Geert GruwezOracle dbaCommented:
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
0
 
Geert GruwezOracle dbaCommented:
jymiX ... parameters ... parameters ... parameters  ?
0
 
KoenVandemoortelCommented:
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 '''%€%''';
 
0
 
Geert GruwezOracle dbaCommented:
use parameters !
it wil get correctly translated

Query1.SQL.TExt := 'SELECT NAME FROM TABLE1 WHERE NAME LIKE :PARAM';
Query1.ParamByName('PARAM').AsString := '%€%';
Query1.Open;
0
 
Stef MerlijnDeveloperAuthor 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.
0
 
Geert GruwezOracle dbaCommented:
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');
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now