Home > Archive > SQL Server JDBC > March 2005 > Single Quote









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Single Quote
Seribus Dragon

2005-03-30, 7:03 pm

What would be the best way to insert a string value with a ' in it.(like don't)?
Joe Weinstein

2005-03-30, 7:03 pm



Seribus Dragon wrote:

> What would be the best way to insert a string value with a ' in it.(like
> don't)?


//Prepared statements are best for inserting any sort of string data...

PreparedStatement p = c.prepareStatement("update mytable set mycol = ? where mykey = ?");
p.setString(1, "My string with ' in it, etc." );
p.setInt(2, mykeyval);
int rowcount = p.executeUpdate();

Joe Weinstein at BEA

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com