 |
| Classic ASP Components Discussions specific to components in ASP 3. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 24th, 2004, 10:36 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Inserting special characters into Access 97
Hi
I'm trying to insert a ' from a web form into a table in Access but keep getting a sytax error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''SACHIN'S', 'SSS', 'SSSS', 'SSSS', 'NA', 'NA', 'NA', 'NA', 'NA')'.
Is there any way around this problem??
Any help is much appreciated. Thanks in advance.
|
|

March 24th, 2004, 10:54 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In my ASP projects I have these two functions...
Code:
<%
Function PreDB(text)
PreDB = Replace(text, "'", "''")
End Function
%>
<%
Function PostDB(text)
PostDB = Replace(text, "''", "'")
End Function
%>
They will probably give you an idea how to continue. I think I used an Access 2000 database, but I think it is the same.
Hope it helps!
Jacob.
|
|

April 7th, 2004, 07:59 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
it worked a treat, thanks for all your help mate
|
|

April 7th, 2004, 08:07 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Jacob,
Just wondering, but what do you use PostDB for?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

April 14th, 2004, 04:02 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I didn't use PostDB, only the replace function.
|
|

April 14th, 2004, 06:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar, sorry for the late reply...
When I used classic ASP I used this as a general function that would enable me to do some commands on strings retrieved from the database. The function posted does not have much functionality, but it could have why it is nice to have one common function for these procedures!
E.g. if I would like to replace all '<'- and/or '>'-signs so that tags is not rendered when shown, or if one was developing a forum then it would be nice to be able to replace special character combinations with e.g. emoticons!
So PostDB refers to the procedures carried out after the database (when retrieving).
Jacob.
|
|

April 14th, 2004, 07:23 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Right, I see.
I also see the use of general replacement functions, like changing the < and >
However, when you send a double single quote to the database to insert a single quote, all that is inserted is the actual single quote. You double them just to tell the database that it should insert the literal value of the quote, and to not try to give it a special meaning.
So, the PostDB method you posted either does nothing (there is nothing to replace), or you're messing up your data by replacing two literal single quotes, with one (that is, it was the initial intention of the one who created the record to insert two single quotes).
The point is, for these kind of database inserts, escaping certain characters is a one-way process: only when you insert stuff should you need to escape them.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Spybreak! (short one) by Propellerheads (Track 2 from the album: The Matrix - Movie Soundtrack)
|
|
 |