Click here to Skip to main content
15,883,811 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
private void btndeleteActionPerformed(java.awt.event.ActionEvent evt) {                                          
             
        try{
            
            theQuery("delete from authors where id = "+authorIDLabel.getText());
        
        
        }
        
        catch (Exception ex){}
        
        
    }
Posted
Updated 22-Jan-16 2:21am
v2
Comments
Richard Deeming 21-Jan-16 11:58am    
Your code is vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
Kevin Marois 21-Jan-16 11:59am    
What is the value of authorIDLabel? Did you try running the command directly in DB?
jame01 21-Jan-16 16:58pm    
you wanna delete selected value from datagridview
Herman<T>.Instance 22-Jan-16 8:21am    
is ID a number or a text?

1 solution

Java
theQuery("delete from authors where id = '"+authorIDLabel.getText()+"'");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900