Hi all, Im unable to insert text data into a table when the text im trying insert has quotes. Ex: String sql1="INSERT into project VALUES ('"+project+"','"+desc+"')"; int status1=st1.executeUpdate(sql1); the above code is working fine as long as im inserting text data with out quotes. However, its failing when im triyng to insert text data which contains quotes. How can i insert text data that has quotes into a table. Im using MS Access as back end. regards satish
have you tried using a PreparedStatement instead? It makes problems like that go away.
Joined: Apr 02, 2003
Hi Satish, welcome to the Java Ranch I haven't tried this but I know it works in ASP so I expect it should also work in Java... You need to enclose the actual text with single ' so you end up with String sql1="INSERT into project VALUES ('"' +project+ '"','"' +desc+ '"')";