Subject Re: locate O'Connor
Author Adam
--- In, "delphigurusam" <shunt@n...>
> FB 1.5.2 B:4731
> sql.strings[2]:='where
> upper(Last_Name)='+#39+uppercase(dbeditLastName.Text)+#39+' ';
> errors when dbeditLastName.Text contains an apostrophe (single quote)
> in the name, as in O'Connor. The query reports that "Connor" is an
> unknown token.
> I know I should be able to figure this out, but I'm feeling brain dead
> and I need this tonight (if possible). Anyone out there want to help
> a "delphidummy"?
> Thx
> Sam Hunt

Sam, use parameters, it takes care of that for you.

In the Query Component.

select id, name, blah
from employee
where Upper(LastName) = :LastName

Go to params, select LastName and make the field type ftString, and
ParamType = ptInput.

Now to your other routine, instead of stuffing around with string

qry.parambyname('lastname').value := UpperCase(dbeditLastName.Text);

Then you can run the query.

If you do need to dynamically build the query, then you will need to do
a stringreplace to replace all #39 with #39+#39, but the param route is
a better (and safer) way to go.