Solved

Delphi TIBQuery.SQL.Text contains ' gives an error

Posted on 2006-07-04
3
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 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