PC Review


Reply
Thread Tools Rate Thread

Database Results problem - apostrophe?

 
 
Stephen Green
Guest
Posts: n/a
 
      14th Oct 2004
I have a Data Results Page that works fine, except for one search. The only
reason I can think of for this failure is that the search term includes an
apostrophe (Raven's Tale).

The query is below. It's looking for e-mail addresses of writers attached
to particular projects (mostly names of plays). I gather that the issue is
with the WHERE clause toward the end.

SELECT Projects.ProjectID, Projects.ProjectType, Projects.ProjectGroup,
Projects.ProjectName, Projects.ProjectDescription, Projects.[Project
Credit], Project_Writers.ID, Project_Writers.Book, Project_Writers.Lyrics,
Project_Writers.Music, Members.LastName, Members.FirstName, Members.Address,
Members.City, Members.State, Members.Code, Members.HomePhone,
Members.WorkPhone, Members.CellPhone, Members.EmailAddress
FROM Projects INNER JOIN (Members INNER JOIN Project_Writers ON Members.ID =
Project_Writers.ID) ON Projects.ProjectID = Project_Writers.ProjectID WHERE
(Projects.ProjectID = ::ProjectID: ORDER BY LastName ASC,FirstName ASC;

Is there a way to adjust the query to account for possible apostrophes?

Thanks.

Stephen


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
Guest
Posts: n/a
 
      15th Oct 2004
With SQL Server, the WHERE can use REPLACE(searchValue, '''','''''')

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Stephen Green" wrote:

> I have a Data Results Page that works fine, except for one search. The only
> reason I can think of for this failure is that the search term includes an
> apostrophe (Raven's Tale).
>
> The query is below. It's looking for e-mail addresses of writers attached
> to particular projects (mostly names of plays). I gather that the issue is
> with the WHERE clause toward the end.
>
> SELECT Projects.ProjectID, Projects.ProjectType, Projects.ProjectGroup,
> Projects.ProjectName, Projects.ProjectDescription, Projects.[Project
> Credit], Project_Writers.ID, Project_Writers.Book, Project_Writers.Lyrics,
> Project_Writers.Music, Members.LastName, Members.FirstName, Members.Address,
> Members.City, Members.State, Members.Code, Members.HomePhone,
> Members.WorkPhone, Members.CellPhone, Members.EmailAddress
> FROM Projects INNER JOIN (Members INNER JOIN Project_Writers ON Members.ID =
> Project_Writers.ID) ON Projects.ProjectID = Project_Writers.ProjectID WHERE
> (Projects.ProjectID = ::ProjectID: ORDER BY LastName ASC,FirstName ASC;
>
> Is there a way to adjust the query to account for possible apostrophes?
>
> Thanks.
>
> Stephen
>
>
>

 
Reply With Quote
 
Stephen Green
Guest
Posts: n/a
 
      15th Oct 2004
Gregory!

Thanks for the reply. I'm having trouble reading the quotes/apostrophes on
my monitor. Are there single and double quotes there? The only offending
title at the moment is A Raven's Tale.

You know, now that I think of it, I included the wrong query. The query
that deals with the actual ProjectName field is a drop down SELECT that
currently reads:

SELECT ProjectID, ProjectName FROM Projects

The ProjectName is displayed/selected and the respective ProjectID is stored
to a variable.

Can I use the REPLACE in the SELECT statement?

Thanks again.

Stephen


"Cowboy (Gregory A. Beamer) - MVP" <(E-Mail Removed)> wrote
in message news:5CFEA842-0CBF-46AB-BFC2-(E-Mail Removed)...
> With SQL Server, the WHERE can use REPLACE(searchValue, '''','''''')
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
> "Stephen Green" wrote:
>
> > I have a Data Results Page that works fine, except for one search. The

only
> > reason I can think of for this failure is that the search term includes

an
> > apostrophe (Raven's Tale).
> >
> > The query is below. It's looking for e-mail addresses of writers

attached
> > to particular projects (mostly names of plays). I gather that the issue

is
> > with the WHERE clause toward the end.
> >
> > SELECT Projects.ProjectID, Projects.ProjectType, Projects.ProjectGroup,
> > Projects.ProjectName, Projects.ProjectDescription, Projects.[Project
> > Credit], Project_Writers.ID, Project_Writers.Book,

Project_Writers.Lyrics,
> > Project_Writers.Music, Members.LastName, Members.FirstName,

Members.Address,
> > Members.City, Members.State, Members.Code, Members.HomePhone,
> > Members.WorkPhone, Members.CellPhone, Members.EmailAddress
> > FROM Projects INNER JOIN (Members INNER JOIN Project_Writers ON

Members.ID =
> > Project_Writers.ID) ON Projects.ProjectID = Project_Writers.ProjectID

WHERE
> > (Projects.ProjectID = ::ProjectID: ORDER BY LastName ASC,FirstName

ASC;
> >
> > Is there a way to adjust the query to account for possible apostrophes?
> >
> > Thanks.
> >
> > Stephen
> >
> >
> >



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      15th Oct 2004
Sure Stephen,

In SQL, the single quote (apostrophe) is the delimiter for a string, or text
value, such as:

SELECT * FROM MyTable WHERE LastName = 'Smith'

To insert a literal single quote into a string in a SQL Statement, you
escape it by doubling:

SELECT * FROM MyTable WHERE LastName = 'O''Toole'

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Stephen Green" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a Data Results Page that works fine, except for one search. The

only
> reason I can think of for this failure is that the search term includes an
> apostrophe (Raven's Tale).
>
> The query is below. It's looking for e-mail addresses of writers attached
> to particular projects (mostly names of plays). I gather that the issue

is
> with the WHERE clause toward the end.
>
> SELECT Projects.ProjectID, Projects.ProjectType, Projects.ProjectGroup,
> Projects.ProjectName, Projects.ProjectDescription, Projects.[Project
> Credit], Project_Writers.ID, Project_Writers.Book, Project_Writers.Lyrics,
> Project_Writers.Music, Members.LastName, Members.FirstName,

Members.Address,
> Members.City, Members.State, Members.Code, Members.HomePhone,
> Members.WorkPhone, Members.CellPhone, Members.EmailAddress
> FROM Projects INNER JOIN (Members INNER JOIN Project_Writers ON Members.ID

=
> Project_Writers.ID) ON Projects.ProjectID = Project_Writers.ProjectID

WHERE
> (Projects.ProjectID = ::ProjectID: ORDER BY LastName ASC,FirstName ASC;
>
> Is there a way to adjust the query to account for possible apostrophes?
>
> Thanks.
>
> Stephen
>
>



 
Reply With Quote
 
Stephen Green
Guest
Posts: n/a
 
      15th Oct 2004
Thanks, Kevin!

But what if the apostrophe isn't what's used in the comparison?

I have a drop down from which to select Project Names (one of which is A
Raven's Tale) - the related ProjectID is saved.

Then a Database Result form that displays data from a different table based
on a comparison of that Project ID - [(WHERE (Projects.ProjectID =
::ProjectID:.

I'm not sure that it is the cause of the malfunction, but I suppose that
since the comma is in the Project Name, the query fails.

All of the other titles (none of the others have apostrophes) work fine.

Thanks so much for helping.

Stephen


"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sure Stephen,
>
> In SQL, the single quote (apostrophe) is the delimiter for a string, or

text
> value, such as:
>
> SELECT * FROM MyTable WHERE LastName = 'Smith'
>
> To insert a literal single quote into a string in a SQL Statement, you
> escape it by doubling:
>
> SELECT * FROM MyTable WHERE LastName = 'O''Toole'
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> I get paid good money to
> solve puzzles for a living
>
> "Stephen Green" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have a Data Results Page that works fine, except for one search. The

> only
> > reason I can think of for this failure is that the search term includes

an
> > apostrophe (Raven's Tale).
> >
> > The query is below. It's looking for e-mail addresses of writers

attached
> > to particular projects (mostly names of plays). I gather that the issue

> is
> > with the WHERE clause toward the end.
> >
> > SELECT Projects.ProjectID, Projects.ProjectType, Projects.ProjectGroup,
> > Projects.ProjectName, Projects.ProjectDescription, Projects.[Project
> > Credit], Project_Writers.ID, Project_Writers.Book,

Project_Writers.Lyrics,
> > Project_Writers.Music, Members.LastName, Members.FirstName,

> Members.Address,
> > Members.City, Members.State, Members.Code, Members.HomePhone,
> > Members.WorkPhone, Members.CellPhone, Members.EmailAddress
> > FROM Projects INNER JOIN (Members INNER JOIN Project_Writers ON

Members.ID
> =
> > Project_Writers.ID) ON Projects.ProjectID = Project_Writers.ProjectID

> WHERE
> > (Projects.ProjectID = ::ProjectID: ORDER BY LastName ASC,FirstName

ASC;
> >
> > Is there a way to adjust the query to account for possible apostrophes?
> >
> > Thanks.
> >
> > Stephen
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database results format problem MickB Tenerife Microsoft Frontpage 5 25th Mar 2010 12:50 PM
Database Results Dropdown Imbedded in Other Database Results form Nicholas Microsoft Frontpage 0 29th Jul 2004 07:17 PM
Database Results Problem Sim Marsh Microsoft Frontpage 15 13th Jan 2004 02:04 PM
Database results problem Steve Grosz Microsoft Frontpage 7 9th Jan 2004 11:53 AM
Problem in my database results regions samuel Microsoft Frontpage 1 31st Aug 2003 03:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:47 AM.