Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2005, 04:44 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replace quotes with other character

I have a memo field where the user enters text and this then updates the database, this works fine until the user enters a quote and of course the SQL query then fails. How can I remove all quotes and replace them with a different character?

Thanks
Louisa

 
Old April 19th, 2005, 06:04 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

How do you do the update?? are you using the SqlCommand or OleDBCommand to do the update. If you use that you can eliminate the problem

Regards
Ganesh
 
Old April 19th, 2005, 06:05 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Please reply if you need furthur help

Regards
Ganesh
 
Old April 19th, 2005, 07:55 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by r_ganesh76
 are you using the SqlCommand or OleDBCommand to do the update. If you use that you can eliminate the problem

Not entirely true: If you use Parameters in the Command objects then you don't have to worry about quote escaping. Just using a Command object alone isn't enough. You have to use it correctly.

Louisa,
It's just a matter of replacing ' with '' in your command text.

-Peter
 
Old April 19th, 2005, 08:10 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do use SQL to update the database, but how can I replace the ' ' with ""?

Thanks Louisa

 
Old April 19th, 2005, 08:21 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

A SQL query should only care about the single quote.

memoFieldValue.Replace("'", "''")
 
Old April 19th, 2005, 08:38 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perfect thanks very much

Louisa

 
Old April 19th, 2005, 11:08 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Sorry I missed out that.

Quote:
quote:Originally posted by planoie
 
Quote:
quote:Originally posted by r_ganesh76
Quote:
 are you using the SqlCommand or OleDBCommand to do the update. If you use that you can eliminate the problem

Not entirely true: If you use Parameters in the Command objects then you don't have to worry about quote escaping. Just using a Command object alone isn't enough. You have to use it correctly.

Louisa,
It's just a matter of replacing ' with '' in your command text.

-Peter
Regards
Ganesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Quotes Not appearing Until I type next character Darryl Rearson Access VBA 2 April 1st, 2008 08:33 AM
Replace character gregalb SQL Server 2000 6 July 12th, 2007 01:14 AM
escape character for double quotes Andy dg C# 2005 3 March 15th, 2007 10:51 PM
SQL REPLACE after a character. Stuart Stalker SQL Server 2000 6 April 11th, 2006 02:13 PM
Character replace function? echovue Access 2 December 21st, 2004 01:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.