Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ArthurKay
Starting Member
7 Posts |
Posted - 2007-05-07 : 13:10:21
|
I am having weird trouble with READING data from my Access database where the field has an apostrophe - but only when I display the field in a textbox.For example, the field "Don't do this" becomes "Don" when my SQL query outputs the result:campaignID = rscampaign("campaign")response.write "<input type='hidden' name='campaignid1' value='" & campaignID & "'>"If I output to regular HTML (e.g. in a <P> tag), the field displays correcly.Has anyone ever encountered this problem? I can't figure out why the textbox would be creating this problem... |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-07 : 13:24:35
|
try replacing ' with & apos ; (remove spaces before and after apos) www.elsasoft.org |
 |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2007-05-07 : 13:27:57
|
| You can also consider using Server.HTMLEncode method.Server.HTMLEncode(campaignID) |
 |
|
|
ArthurKay
Starting Member
7 Posts |
Posted - 2007-05-07 : 14:01:52
|
| Both are great suggestions... except I cannot get them to work.If I replace the ' with & apos ; (without spaces) when saving to the database, it takes that litterally.and it seems to ignore the server.htmlencode.. |
 |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2007-05-07 : 14:17:42
|
| Could you please post the code for both the examples you tried? |
 |
|
|
ArthurKay
Starting Member
7 Posts |
Posted - 2007-05-07 : 14:27:14
|
First, I tried:campaignID = rscampaign("campaign")response.write "<input type='hidden' name='campaignid1' value='" & server.HTMLEncode(campaignID) & "'>"and then I triedcampaignID = server.HTMLEncode(rscampaign("campaign"))response.write "<input type='hidden' name='campaignid1' value='" & campaignID & "'>"Neither of these worked.I also tried replacing the apostrophe with ' when I write to the database, but when I output the variable "campaignID", it displays Don't instead of "Don't" (the string is taken literally, not as html) |
 |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2007-05-07 : 15:03:19
|
| Try using double quotes for enclosing the values - <% response.write "<input type='text' name='campaignid1' value=""" & campaignID & """/>" %> |
 |
|
|
ArthurKay
Starting Member
7 Posts |
Posted - 2007-05-07 : 15:28:47
|
| That worked!!! Thanks! |
 |
|
|
|
|
|