473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

HtmlEncode and apostrophes

Hi

I'm trying to code up an admin system for my website. A couple of the
welcome text paragraphs are stored in an SQL database, so that we can update
them should we need to. However, even though I'm using the HTMLEncode method
(I've also tried the URLEncode method), the apostrophe always remains, and
then when I try and do the update query, I get...

Unclosed quotation mark after the character string

The SQL is UPDATE StaticPages SET Text = 'blah' WHERE PageID = 'ABOUT'

The code only breaks when the Text variable contains an apostrophe. But, I'm
using an encoding method? Why is the apostrophe not being encoded?

Thanks,
Dan
Mar 31 '08 #1
2 2742
the sql never hits the page, and is not shown - - it's not an HTML/urlEncode
situation - -
you'd need to double the single quotes to get SQL to recognize it, since the
update statement is a string - -
But first - I'd suggest not doing it with concatenation this way - used
parameterized queries:
http://www.aspnet101.com/aspnet101/tutorials.aspx?id=1 (2 part tutorial)
David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"musosdev" <mu*******@community.nospamwrote in message
news:8E**********************************@microsof t.com...
Hi

I'm trying to code up an admin system for my website. A couple of the
welcome text paragraphs are stored in an SQL database, so that we can
update
them should we need to. However, even though I'm using the HTMLEncode
method
(I've also tried the URLEncode method), the apostrophe always remains, and
then when I try and do the update query, I get...

Unclosed quotation mark after the character string

The SQL is UPDATE StaticPages SET Text = 'blah' WHERE PageID = 'ABOUT'

The code only breaks when the Text variable contains an apostrophe. But,
I'm
using an encoding method? Why is the apostrophe not being encoded?

Thanks,
Dan

Mar 31 '08 #2
Thanks David - Parameterised queries worked first time! A good one to remember!

"David Wier" wrote:
the sql never hits the page, and is not shown - - it's not an HTML/urlEncode
situation - -
you'd need to double the single quotes to get SQL to recognize it, since the
update statement is a string - -
But first - I'd suggest not doing it with concatenation this way - used
parameterized queries:
http://www.aspnet101.com/aspnet101/tutorials.aspx?id=1 (2 part tutorial)
David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"musosdev" <mu*******@community.nospamwrote in message
news:8E**********************************@microsof t.com...
Hi

I'm trying to code up an admin system for my website. A couple of the
welcome text paragraphs are stored in an SQL database, so that we can
update
them should we need to. However, even though I'm using the HTMLEncode
method
(I've also tried the URLEncode method), the apostrophe always remains, and
then when I try and do the update query, I get...

Unclosed quotation mark after the character string

The SQL is UPDATE StaticPages SET Text = 'blah' WHERE PageID = 'ABOUT'

The code only breaks when the Text variable contains an apostrophe. But,
I'm
using an encoding method? Why is the apostrophe not being encoded?

Thanks,
Dan


Mar 31 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James Foreman | last post by:
I've got a set of emails in a table, where sometimes they've failed to input the @ properly. Eg james.foreman'abcmail.co.uk How do I write a replace to deal with that? Also, I've got a set...
3
by: Richard Hollenbeck | last post by:
I have an email field and a command button to send email. The problem is that when the email program opens up there are apostrophes around the email address that I have to manually remove before...
4
by: Andrea Williams | last post by:
I have a class that imports System.Web.UI.Page. The code below works: public string JScriptEncode(string strValue) { strValue = strValue.Replace(@"'", "\x27"); //' JScript encode...
3
by: Michael Gaillez | last post by:
Hi, I'm dynamically loading an assembly into an ASP.NET application. In the control that I load from that dynamic assembly I've tried to use Server.HTMLEncode but this results in a serious...
4
by: Andy Fish | last post by:
When using databinding, I have gotten into the habit of using single quotes (apostrophe) round attribute values rather than double quotes because this allows visual studio to work when there are...
3
by: David Lozzi | last post by:
Howdy, I have my left navigation of Hyperlinks, and part of the link's querystring is the title of the page they are going to. For example, one of the pages is Cars & Trucks. With HtmlEncode, it...
1
by: Marco Miltenburg | last post by:
While working on some multilingual code I found a rather strange thing happening with Server.HTMLEncode. While loading different languages I change the Codepage and Charset in ASP to reflect the...
1
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is...
4
by: Lucanos | last post by:
Hey Guys, Probably a simple question, but one I am struggling with all the same. I know that in PHP you wrap a text string in apostrophes or quotations - (examples $variable = 'this string' OR...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.