?
Solved

URGENT!!!-Sql statement

Posted on 2003-12-11
5
Medium Priority
?
258 Views
Last Modified: 2010-04-01
i need to have a sql statement like thiw:

String Query = "delete FROM userskills where username='"+vol.getUsername()+"' "and skill='"+request.getParameter("id")+"'";
  but i get error, i think the way i right sql statement not so ok.

thanks
0
Comment
Question by:Jasbir21
  • 4
5 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 9919920
String Query = "delete FROM userskills where username='"+vol.getUsername()+"' and skill='"+request.getParameter("id")+"'";
0
 
LVL 35

Accepted Solution

by:
TimYates earned 260 total points
ID: 9919939
better is:

PreparedStatement stmt = conn.prepareStatement( "delete FROM userskills where username=? and skill=?" ) ;
stmt.setString( 1, vol.getUsername() ) ;
stmt.setString( 2, request.getParameter( "id" ) ) ;
stmt.executeUpdate() ;

(don't forget to close your statement)

This way, you can't have problems with "SQL injection"

0
 

Author Comment

by:Jasbir21
ID: 9919993
thank you very much.

0
 
LVL 35

Expert Comment

by:TimYates
ID: 9920036
:-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
Applications for our next round of the Experts Exchange Scholarship Contest are starting to roll in. It made us wonder what our past winners are up to these days. Here's a look at what four winners experienced with the contest and what they're doing…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question