Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error

 
sona raj
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
this is to delete record from database, no error is been showed but the record is not been deleted from database.'m using ms access.


if(JTPersonalTable.getValueAt(JTPersonalTable.getSelectedRow(),JTPersonalTable.getSelectedColumn()) != null){
System.out.println(JTPersonalTable.getValueAt(JTPersonalTable.getSelectedRow(),JTPersonalTable.getSelectedColumn()));
String ObjButtons[] = {"Yes","No"};
int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to delete the selected record?","Delete Record",JOptionPane.DEFAULT_OPTION,JOptionPane.ERROR_MESSAGE,null,ObjButtons,ObjButtons[1]);
if(PromptResult==0){
stPersonal.executeUpdate("DELETE * FROM tblPersonal WHERE PersonalIndex= " + JTPersonalTable.getValueAt(JTPersonalTable.getSelectedRow(),0));
System.out.println(JTPersonalTable.getValueAt(JTPersonalTable.getSelectedRow(),0));
reloadRecord();
JOptionPane.showMessageDialog(null,"Record has been successfully deleted.","Comfirm Delete",JOptionPane.INFORMATION_MESSAGE);
}
}
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try either setting autocommit(true) on the connection or doing a dummy select after the delete. This is a common bug in the JDBC-ODBC bridge.

In future, please use a meaningful topic and use the code tags. You can see more hints on writing questions better in my signature...

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic