Solved

Delphi TIBQuery.SQL.Text contains ' gives an error

Posted on 2006-07-04
3
285 Views
Last Modified: 2010-04-05
Hi Experts,

When executing a query runtime in Delphi which contains a " ' " (single quote) I terminates the query in gives an error?
What is the correct why of working with params which contains a ' ?

If not mistaken I am looking for something similar than PHP's stripslashes().

Thanks in advance!
0
Comment
Question by:Marius0188
3 Comments
 

Author Comment

by:Marius0188
ID: 17038021
For that matter please show me how to handle any invalid characters in a query params?
0
 
LVL 4

Expert Comment

by:kenpem
ID: 17038218
If the content of the query is under complete control of the code, use TWO single quotes within the string, as in:

Qry.SQL.Text := 'It doesn''t matter';

This is standard Object Pascal, to embed a single quote without terminating the string.

If possible, use the parameter functions to avoid conflicts:

Qry.SQL.Text := 'UPDATE Customer SET CustName = :uName';
Qry.ParamByName('uName') := EditBox1.Text;   // note that param syntax changes depending on BDE/ADO choice.

and now it shouldn't matter if the name is O'Donnell.

Hope this helps. Otherwise, paste here the bit of code that's bothering you and we'll have a go.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 17040607
there is also a quotedstr-function,
which does the double of the quotes if needed

meikl :-)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now