Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Apostrophe, Input Field

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,49258
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Apostrophe, Input Field
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Apostrophe, Input Field - 7/10/2007 3:55:54 AM   
  hcky21

 

Posts: 4
Score: 0
Joined: 7/10/2007
Status: offline
Hello,

I am struggling with users typing in an apostrophe in an input field and the VBScript not being able to accept it.

Example:

User inputs a customer name, i.e. O'reily, in a input field
When info is submitted, there is an error because of the apostrophe

This ' is obviously needed because it is a customer's name
how can I work-around this so that the VBScript will accept when info is submitted

thanks for your help.
 
 
Post #: 1
 
 RE: Apostrophe, Input Field - 7/10/2007 4:20:41 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
Please post your code.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to hcky21)
 
 
Post #: 2
 
 RE: Apostrophe, Input Field - 7/10/2007 5:14:00 AM   
  hcky21

 

Posts: 4
Score: 0
Joined: 7/10/2007
Status: offline
To be more specific: the problem is with the City Name, such as Coeur D'Alene

'5. Prepare ship to address for the listed address.
If request.querystring("ShipToID") >0 Then
sqlstr8 = "Select * from AddressBook where ID = '" & request.querystring("ShipToID") & "'"
Set ors8=conn.execute(sqlstr8)
End If

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Apostrophe, Input Field - 7/10/2007 6:20:03 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
Aah...so the actual problem is in the query not the VBS itself. I don't remember how to escape ' in SQL but that is what you need to do.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to hcky21)
 
 
Post #: 4
 
 RE: Apostrophe, Input Field - 7/10/2007 6:22:16 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
try this:

sqlstr8 = "Select * from AddressBook where ID = '" & Replace(request.querystring("ShipToID"), "'", "''") & "'"

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Apostrophe, Input Field - 7/10/2007 6:49:39 AM   
  hcky21

 

Posts: 4
Score: 0
Joined: 7/10/2007
Status: offline
I see, thank for for helping even though it isn't a VBScript issue.  However, it did not work, I am getting this error:


Microsoft OLE DB Provider for SQL Server error '80040e14'
Line 1: Incorrect syntax near 'ALENE'.




(in reply to ebgreen)
 
 
Post #: 6
 
 RE: Apostrophe, Input Field - 7/10/2007 7:42:04 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
Basicly you just need to find out how the DB you are querying handles escaping ' then structure your query string accordingly.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to hcky21)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Apostrophe, Input Field Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts