You need to put it within two more apostrophes so ' becomes '''. If
you are writing your query to do this in Delphi, try adding a
parameter to the query and pass the parameter including your
apostrophe into the statement. You can put in the wildcard statement
into your query including the parameter.
Using your example this would be something like,
SELECT
statenotified, notary_id, LastName, FirstName,
MiddleInitial, Indep, Book_number, Page_number,
CloseRec, TermBegins, TermEnds, DatePickedUp, FailedToQualify,
Notes, SOSLtrSent
FROM
notaries
WHERE
LastName LIKE '%' + :myParam + '%'
/*Wildcard added to either end if you need it*/
AND CloseRec = 1
Order By
lastname
Then in your code, something like
Query.Parameters.ParamByName('myParam').Value := edtLastName.Text;
Put this in before you run your query and it should work.
This way, you pass the value which will include the apostrophe to the
parameter instead of trying to pass the text which gets a little
confusing. Using the example above, it will run the SQL for anything
in your parameter. If you wanted to find a single apostrophe, then you
can pass a single one into your parameter. So you could use :
Query.Parameters.ParamByName('myParam').Value := ''';
Best of luck
Ryan
www.ryan.dial.pipex.com st*****@gw.co.jackson.mo.us (Michael Sterling) wrote in message news:<f7**************************@posting.google. com>...
i'm using delphi 7 and have a query in which i'm trying to find names
that have an apostrophe in them, i.e. "o'mally". my problem is that
when i write my select statement i can't get the quotes right. i get
all types of errors no matter what i try. i get "missing right quote",
"invalid token" etc. i've tried using QuotedStr and nothing works.
here is my current attempt in which i get an "invalid use of keyword.
token: n'%'"
sSQL := 'SELECT statenotified, notary_id, LastName, FirstName,' +
' MiddleInitial, Indep, Book_number, Page_number,' +
' CloseRec, TermBegins, TermEnds, DatePickedUp,
FailedToQualify,' +
' Notes, SOSLtrSent FROM notaries WHERE LastName LIKE '''+
''+ edtLastName.Text+'+''%'' AND CloseRec = 1 order by
lastname';