Article View: borland.public.interbase.sql
Article #446Re: Single quotes in IB7 field values
From: Brian
Date: Tue, 18 Mar 2008 18:52
Date: Tue, 18 Mar 2008 18:52
37 lines
2243 bytes
2243 bytes
In article <47dfcc00$1@newsgroups.borland.com>, "Wayne Niddery \(TeamB
\)" <wniddery@chaffaci.on.ca> says...
> "Brian" <AAA@AAA.AA> wrote in message
> news:MPG.22498b10b5e30cfa989680@newsgroups.borland.com...
> > My OCCUPANT_NAME field in my OCCUPANTS table contains some values
> > with single quotes like Fred's Market for instance.
> > Are there any escape characters I can use in My SQL strings?
> > My front end application is Access2007 and I am using the DataDirect
> > ODBC driver.
> > Earlier versions of IB used to accept double quotes around a fields
> > value.
>
>
> If you are formatting SQL directly instead of using parameters then you must
> double up single quotes, e.g:
>
> s := 'where name = ''Fred''s Market''';
>
> Delphi also has a QuotedStr function that makes this easier, e.g. if a user
> enters Fred's Market in an edit control:
>
> s := 'where name = ' + QuotedStr(Edit1.Text);
>
> However, the best way to avoid these issues is to use parameterized queries.
> Assign the SQL to the dataset as:
>
> MyDataset.SQL.Text := 'select * from table where name = :name';
>
> Then assign the parameter(s):
>
> MyDataset.ParamByName('name') := Edit1.Text;
>
>
>
Thanks. I'll try it. I may have forgotten to disclose that I am trying
updates and inserts as we..
Thanks much for your reply sir.
Technical Details
Message-ID:
<MPG.2249d97123e5c8989682@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<MPG.22498b10b5e30cfa989680@newsgroups.borland.com> <47dfcc00$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,55d6efaf53aa5888 X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Brian <AAA@AAA.AA> Newsgroups: borland.public.interbase.sql Subject: Re: Single quotes in IB7 field values Date: Tue, 18 Mar 2008 14:52:21 -0400 Message-ID: <MPG.2249d97123e5c8989682@newsgroups.borland.com> References: <MPG.22498b10b5e30cfa989680@newsgroups.borland.com> <47dfcc00$1@newsgroups.borland.com> Organization: Brainhose X-Newsreader: MicroPlanet Gravity v2.60 NNTP-Posting-Host: 75.67.232.179 X-Trace: newsgroups.borland.com 1205866342 75.67.232.179 (18 Mar 2008 11:52:22 -0700) Lines: 37 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail