Hey,
The syntax is correct now, the program compiles with 0 errors. But the removal is not done, I do not understand why and it does not display the error message that I specify. This is the code if you can still help me,
Code:
if(B == VSupprim)
{
if((SCode.getText().equals(""))||(Snom.getText().equals(""))||(SPrenom.getText().equals("")))
{/ / Error message.
JOptionPane.showMessageDialog(null, "All fields must be filled","Standard", JOptionPane.ERROR_MESSAGE);
}
else
{
String ccd = sCode.getText();
String = CNOM Snom.getText();
String cpnm = SPrenom.getText();
String query ="DELETE FROM users WHERE code = '"+ + ccd" 'AND name ='"+ + CNOM" 'AND FirstName ='"+ + cpnm"'";
try
{/ / connection to the database and execute statement
Class.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc: odbc: Database");
Statement st = conn.createStatement();
int nb = st.executeUpdate(query);
if (nb ==0)
{/ / Error message.
JOptionPane.showMessageDialog(null, "Error while deleting","Message", JOptionPane.WARNING_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null, "User deleted successfully","Message", JOptionPane.INFORMATION_MESSAGE);
}
st.close();
conn.close();
}
catch(Exception eb){
}
}
}
Bookmarks