Solved

Code cuts off input at apostrophe(')

Posted on 2000-05-08
5
202 Views
Last Modified: 2008-03-06
When sending form data to my database, sometimes the input gets cut off if there's an apostrophe. E.g.: "Bob's House of Fun" makes it to the database only as "Bob". Is there an easy fix for this?
0
Comment
Question by:jstohler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
CoolAss earned 100 total points
ID: 2790538
I usually post this stuff as a comment, but this is an easy one. :-)

Simple use the VBScript replace command to replace ever ' with a ''. This will prevent termination of the code.

As in:

MySQLString = "Bob's House of Goats"

Replace MySQLString, "'", "''"

or

MySQLString = Replace(MySQLString, "'", "''")

Both with work.
0
 
LVL 4

Expert Comment

by:CoolAss
ID: 2790549
Wow... guess I typed to fast.

The above should be:

Simply use the VBScript replace command to replace every ' (single apostrophe) with a '' (double apostrophe). This will prevent termination of the code.

As in:

MySQLString = "Bob's House of Goats"

Replace MySQLString, "'", "''"

objRS.Open MySQLString

or

MySQLString = Replace(MySQLString, "'", "''")

objRS.Open MySQLString

Both with work.


0
 

Author Comment

by:jstohler
ID: 2790560
I never used replace before, but it looks easy enough. Can I use a line like:

objRec("Sitename") = replace(Request.Form("requiredSiteName")"'","''")

or does it need to be an independent command?
0
 
LVL 4

Expert Comment

by:CoolAss
ID: 2790986
Sure... that will work fine.
0
 

Author Comment

by:jstohler
ID: 2792330
Thanks! Great response time, too.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Microsoft SQL ADO Conn Issue 6 64
Html Table Looping (part 2) 5 41
Extracting nodes  using classical ASP 3 40
Table doesn't show the lines! 3 36
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question