Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an problem with the insert query

while insertion

since my insert statement contains a name='Frank D'Souza'

Its showing the following error at the time of insertion, Quoted string not properly terminated.

Regards

Sushil Dharmar
Posted
Comments
[no name] 19-Oct-12 7:04am    
Try changing the single quotes enclosing your string with double quotes.
SushilDharmar 19-Oct-12 7:15am    
oracle doesnt supports double Quotes(") at the time of insertion.

Replace 1 Single Quote(') with 2 Single Quotes ('')

The following will work for you...

'Frank D''Souza'
 
Share this answer
 
Solution 1 will work, but I believe there is an underlying problem that usually is the cause of issues like this.
You shouldn't manually have to alter your data.
I'm guessing you are building your query something like this:
C#
var query = "INSERT .... VALUES ('" + yourValue + "');

You should be using a paramaterized query which will take care of this and the potential sql injection attack that your database will be vulnerable to:
C#
using (OracleCommand command = new OracleCommand("INSERT .... VALUES( :Name", connection))
{
   command.Parameters.Add(new OracleParameter("Name", dogName));
   // ... The rest of your code.
}
 
Share this answer
 
v3
Comments
Jörgen Andersson 22-Oct-12 16:02pm    
Question was about Oracle, so I updated your code, otherwise the answer was spot on.
fjdiewornncalwe 22-Oct-12 16:27pm    
Thanks.
Kuthuparakkal

Even I had founded the solution in the same way, when the Value is been inserted into the database, I just used the inbuild function Replace available in asp.net

For Egs:

string nam="Frank D'Souza";
nam=nam.Replace("'","''");
now the inserted value would be
Frank D'Souza only in the DataBase..
not the Frank D''Souza .. :-)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900