• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to construct a sql query when field having single quote

 
zimbu bolleddu
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have been working on web application , here is my requirement:

I'm constructing sql statement dynamically from dynamic user input (form data). In one of the field having single quote.

while executing the query it is getting problem because of single quote .. so how do i resolve my problem.

single quote should be there. (I'm using Ms-Access as my database).

Thanks in advance
zimbu
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please CarefullyChooseOneForum for your post.This ensures desired response for your post.
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Ghorpade:
Please CarefullyChooseOneForum for your post.This ensures desired response for your post.


Moving to JDBC forum.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49845
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a PreparedStatement or passing the text directly? If you have the text directly you may need to convert the ' to \'. I don't know whether PreparedStatements will automatically escape the ' for youi.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
I don't know whether PreparedStatements will automatically escape the ' for you.


Yes , It will escape the single quote (').

Shailesh
 
Campbell Ritchie
Sheriff
Pie
Posts: 49845
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailesh Chandra:
Yes , It will escape the single quote (').

Shailesh
Thank you, and that's good. I hoped that is what it did, but thought I had better say "don't know" because I wasn't sure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic