472,364 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 software developers and data experts.

How to insert text include ( " or ' ) to database?

Kosal
68
Hi I had some problem with asp when i insert string include ' or " in the string I cannot insert to database and error message like:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''For centuries China stood as a leading civilization, outpacing the rest of the world in the arts and sciences. But in the 19th and early 20th centuries, China was beset by civil unrest, major famines, military defeats, and foreign occupation. After World Wa'.
/ptmasia/admin/au_country_exe.asp, line 21


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Avant Browser; .NET CLR 2.0.50727)

Page:
POST 771 bytes to /ptmasia/admin/au_country_exe.asp

POST Data:
idregion=1&country=China&information=For+centuries +China+stood+as+a+leading+civilization%2C+outpacin g+the+rest+of+the+world+in+the+arts+and+sciences.+ But+in+the+19th+and+early+20th+centuries%2C+China+ . . .

Please kinldy help me to solve this problem
Aug 11 '07 #1
2 1625
jhardman
3,406 Expert 2GB
OK, I'll help. But do I have to do it kindly?

Please remember that quote marks (") and single quote marks (') are considered special characters in either VBScript or SQL. Since you are using both to script the page and connect to the db, there are several opportunities to create errors unless you replace them with non-special characters. If you need those characters in the string for the purposes of searching or cataloguing, then you can double them, this let's SQL know that you intend the special character to be inserted in the db:
Expand|Select|Wrap|Line Numbers
  1. description = replace (request("description"), "'", "''") 
  2. 'places two apostrophe's everywhere you have one
On the other hand, if you just want these characters for display purposes, you should "escape them" or replace them entirely with something that will look the same, but not cause errors:
Expand|Select|Wrap|Line Numbers
  1. description = replace (request("description"), """, """) 
  2. 'replaces quote mark with the HTML character code for quote mark
Aug 13 '07 #2
guny
3
or else, you may use chr(34) to substitute ", chr(39) to substitute ' .
Don't forget to use & before and after the code
For instance, text = I'd love to use "Hello World"
Then
string = "I" & chr(39) & "d love to use " & chr(34) & "Hello World" & chr(34)
Aug 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Luc Dal | last post by:
Hello, I've serious problem using ASP under WindowsXP sp2. I get the following reply (sorry it's in french) Erreur de compilation Microsoft VBScript error '800a0401' Fin d'instruction...
4
by: hao | last post by:
Hi, all When I use ASP to insert an record to a database, I got some errors and can not insert any value with Chinese Char. The only way I can do that is use "rst1.Addnew...rst1.update". Anyone...
17
by: NuB | last post by:
I have a sql query that is doing an update of records, how can I add NULL to the field in the database if the field on my screen is blank? example: I have 5 textboxes, and a user can leave some...
3
mmarif4u
by: mmarif4u | last post by:
Hi everybody, I already post a thread like this but that was in mysql. Here i have a problem with all the code,, <?php // signup.php include("common.php"); include("db.php");
1
by: oanhhuynh | last post by:
Hi, I'm designing 1 form include 2 Unbound Object Frame to insert image and memo that describe the product. On database in Access have 2 fields image and description with OLE Object property ...
0
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include...
7
by: dongletran06 | last post by:
Hi, Please help me find out what wrong with my codes in inputting from my form to mysql database using drop down menu. Below is the codes I used. Only the drop down is not working but the "input...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
7
by: tarunkhatri | last post by:
Hi, I want to insert multiple rows in a database table, from an submit form. But not able to trouble shoot the problem in my code. Following is the code. <form action=test_insert.php...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.