Question on delete button

S

smart

Hi, to all i am new to Core java and swings concepts.

I have problem in swings button .

Actually in my application i created one button called DELETE .

i am posted my code help me regarding this topic .


[ int choice = JOptionPane.showConfirmDialog(this,"r u sure
want to delete?","Information",JOptionPane.YES_NO_OPTION);

if(choice==JOptionPane.YES_OPTION)
{
pstmtdel=con.prepareStatement("delete from ICLASS where Sno='"+Sno
+"'");
pstmdel.executeUpdate();

JOptionPane.showMessageDialogthis,"Record
Deleted","Information",JOptionPane.INFORMATION_MESSAGE);
}


else
if(choice==JOptionPane.NO_OPTION)
{
JOptionPane.showMessageDialog(this,"Record Not
Deleted","Information",JOptionPane.INFORMATION_MESSAGE);
}


pstmtdel.executeUpdate();


Now my problem is when i pressing button deleting record even though
when i press NO option.

Now requirement is when i press yes option it's have to delete the
record or if i press no option don't delete record .


Help me Regarding this topic

Thanks in advance
 
H

Hendrik Maryns

smart schreef:
Hi, to all i am new to Core java and swings concepts.

I have problem in swings button .

Actually in my application i created one button called DELETE .

i am posted my code help me regarding this topic .


[ int choice = JOptionPane.showConfirmDialog(this,"r u sure
want to delete?","Information",JOptionPane.YES_NO_OPTION);

Wow, even in user interaction you use leet speak? Wouldn’t recommend this.
if(choice==JOptionPane.YES_OPTION)
{
pstmtdel=con.prepareStatement("delete from ICLASS where Sno='"+Sno
+"'");
pstmdel.executeUpdate();

JOptionPane.showMessageDialogthis,"Record
Deleted","Information",JOptionPane.INFORMATION_MESSAGE);
}


else
if(choice==JOptionPane.NO_OPTION)
{
JOptionPane.showMessageDialog(this,"Record Not
Deleted","Information",JOptionPane.INFORMATION_MESSAGE);
}


pstmtdel.executeUpdate();

What does this do?
Now my problem is when i pressing button deleting record even though
when i press NO option.

I can’t spot anything from the code, please provide an SSCCE:
http://mindprod.com/jgloss/sscce.html

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFIBdO1e+7xMGD3itQRAnedAJ9rK8KJSmEcuW5cCjyZLW7IWakHlACfU0iq
A5Kv+5PyI1XGBoM5nHzOdRg=
=blda
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top