hcky21
-
Total Posts
:
4
- Scores: 0
-
Reward points
:
0
- Joined: 7/10/2007
-
Status: offline
|
Apostrophe, Input Field
Tuesday, July 10, 2007 4:55 AM
( permalink)
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.
|
|
|
|
ebgreen
-
Total Posts
:
8219
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Apostrophe, Input Field
Tuesday, July 10, 2007 5:20 AM
( permalink)
|
|
|
|
hcky21
-
Total Posts
:
4
- Scores: 0
-
Reward points
:
0
- Joined: 7/10/2007
-
Status: offline
|
RE: Apostrophe, Input Field
Tuesday, July 10, 2007 6:14 AM
( permalink)
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
|
|
|
|
ebgreen
-
Total Posts
:
8219
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Apostrophe, Input Field
Tuesday, July 10, 2007 7:20 AM
( permalink)
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.
|
|
|
|
ebgreen
-
Total Posts
:
8219
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Apostrophe, Input Field
Tuesday, July 10, 2007 7:22 AM
( permalink)
try this: sqlstr8 = "Select * from AddressBook where ID = '" & Replace(request.querystring("ShipToID"), "'", "''") & "'"
|
|
|
|
hcky21
-
Total Posts
:
4
- Scores: 0
-
Reward points
:
0
- Joined: 7/10/2007
-
Status: offline
|
RE: Apostrophe, Input Field
Tuesday, July 10, 2007 7:49 AM
( permalink)
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'.
|
|
|
|
ebgreen
-
Total Posts
:
8219
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Apostrophe, Input Field
Tuesday, July 10, 2007 8:42 AM
( permalink)
Basicly you just need to find out how the DB you are querying handles escaping ' then structure your query string accordingly.
|
|
|
|