Re: I want corect code for deletind data from database(SQL)
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Wed, 21 Nov 2007 16:00:31 -0500
Lew wrote:
amit.chhodhary@xxxxxxxxx wrote:selectedName = request.getParameter("Combo Box");
statement.executeUpdate("delete ID,PHONENAME from PHONE where
ID=(select ID from PHONE WHERE PHONENAME= +selectedName ) " );
I want corect code for deletind data from database(SQL);
Snippet:
private static final String SQL =
"delete ID,PHONENAME from PHONE where PHONENAME = ?";
Connection cxn = DriverManager.getConnection( dbUrl );
PreparedStatement ps = cxn.prepareStatement( SQL );
int nRows = ps.executeUpdate();
Program structure and exception handling are obviously omitted.
I think I would use:
private static final String SQL = "delete from PHONE where PHONENAME = ?";
Connection cxn = DriverManager.getConnection( dbUrl );
PreparedStatement ps = cxn.prepareStatement( SQL );
ps.setString(1, selectedName);
int nRows = ps.executeUpdate();
I think you would too.
Arne
.
- Follow-Ups:
- References:
- I want corect code for deletind data from database(SQL)
- From: amit.chhodhary@xxxxxxxxx
- Re: I want corect code for deletind data from database(SQL)
- From: Lew
- I want corect code for deletind data from database(SQL)
- Prev by Date: Re: I want corect code for deletind data from database(SQL)
- Next by Date: Re: I want corect code for deletind data from database(SQL)
- Previous by thread: Re: I want corect code for deletind data from database(SQL)
- Next by thread: Re: I want corect code for deletind data from database(SQL)
- Index(es):