Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem in insert statement

Status
Not open for further replies.

emkay

Programmer
Apr 24, 2001
2
IN
friends,
i'm facing a problem in inserting data in a database where the data contains an apostrophe(').
first i'm extracting some data from a Table(say A)and then after some modification I'm inserting it to another table say(site_table).
the problem arises when i'm trying to insert into site-table a variable whose contents include an apostrophe
after the resultset(rs) of query to extract data from table A i'm giving the following
to insert into site-table
String sname=rs.getString("Name");
String id=rs.getString("School_shortname");
String path="Statement st1=conn.createStatement();
st1.executeUpdate("Insert into site_table(keyword,web_location)values ('"+sname+"','"+path +"')");
st1.close()

I'm getting the following error [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Children's Valley School'.
it is not inserting the above data as it contains an apostrophe.
how do i handle it.Can anybody help me
thanx
 
Hiya,

You need to put extra sets of quotes in to show the database that you are not closing a field, but are using an apostrophie.

Basically, for a single quote to be inserted, you need ''' (three single quotes).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top