How to delete a MySQL database selected record (row) I use this code
connectDB();
try{
java.sql.PreparedStatement stmt = con.prepareStatement("DELETE FROM tbl_codes WHERE No=? ");
String sql = "Delete FROM user WHERE No= "+txt_search_code.getText();
pstmt = con.prepareStatement(sql);
pstmt.setString(1,txt_search_code.getText());
pstmt.execute();
JOptionPane.showMessageDialog(null, " Your new records Deleted Succsessfully!!");
} catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
closeDB();
but it get an error like this -
java.sql.SQLException:Parameter index out of range(1>number of parameters,which is 0)
So how can I fix this probleam....(Examples please) Thanks