Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 problem with converting symbol

Author  Topic 

homstation86
Starting Member

3 Posts

Posted - 2008-06-23 : 21:04:03
hi..
sql statement
db.query(
INSERT INTO student(name, course, email) "+
"VALUES('" + name + "' , "+
"'" + course+"' , "+
"'" + email+"' ");

this sql statement doesn't content any error but if the sentences that want to insert into table contain symbol ' then it will process error when enter into table. ( data contain symbol ' can't insert into table).

May i know how to solve this problem.
i did refer to my friends they said need include java class, but they not sure what's the class that i need.

So i help i can get the help here.
Thank in advance

homstation86
Starting Member

3 Posts

Posted - 2008-06-23 : 21:09:40
i am using mySQL. the code is written in java .
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-23 : 21:29:51
You should post your question on a MySql forum then as this one is for Microsoft SQL Server.

Check out dbforums.com, they have a MySql forum there.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-23 : 21:50:35
If the sentence has a single quote, you need to double it when inserting to a table. Use Replace function

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

homstation86
Starting Member

3 Posts

Posted - 2008-06-24 : 21:05:47
replace function? may i know which replace function that you refer to?
THX for reply
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-25 : 00:49:33
quote:
Originally posted by homstation86

replace function? may i know which replace function that you refer to?
THX for reply



http://www.webmasterworld.com/forum10/8113.htm
Go to Top of Page
   

- Advertisement -