aspose file tools*
The moose likes JSP and the fly likes delete tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "delete tag" Watch "delete tag" New topic
Author

delete tag

vicneswaran boi
Greenhorn

Joined: Sep 06, 2004
Posts: 13
When ever i compile this code i receive the error "no result set".
I do not understand this error>
Thank u for your help
<HTML>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<HEAD>
</HEAD>
<BODY><P><H2>Confirmation of Deletion </H2>
<TABLE BORDER=1 WIDTH="700" CELLPADDING=3 CELLSPACING=1>
<TR>
<TD>ID</TD>
<TD>Committee_Name</TD>
<TD>Commitee_Full</TD>
<TD>Description</TD></TR>
<FORM ACTION="Delete8.jsp" METHOD="POST">
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection("jdbc dbc atabase","","");
Statement statement = connection.createStatement();
int id = Integer.parseInt(request.getParameter("Id"));
ResultSet columns = statement.executeQuery("Delete * FROM Member WHERE Pid ="+ id);
while (columns.next())
{
int Id = columns.getInt("Pid");
String Name = columns.getString("Name");
String CName = columns.getString("CName");
String D = columns.getString("D");
%>
<TR>
<TD><%=Id%></TD>
<TD><%=Name%></TD>
<TD><%=CName%></TD>
<TD><%=D%></TD>
<INPUT TYPE = "HIDDEN" name="Id" value=<%=id%>>
<TD><INPUT TYPE = Submit VALUE ="Select"></TD></TR>
</FORM>
<% }
columns.close(); statement.close(); connection.close();
%>

</FORM>
</TABLE>
</BODY>
</HTML>
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi Vicneswaran Boi,

Welcome to JavaRanch!

Your first problem here is that you're using executeQuery() for a DELETE statement. Obviously a DELETE doesn't return a ResultSet, hence your error. Look at executeUpdate() instead. You will also probably need to change "DELETE * FROM" to "DELETE FROM" unless the database you're using is non-standard. Note also that you shouldn't be using the JDBC/ODBC bridge or Statement (rather than PreparedStatement) unless you're just playing or have no alternative.

In future posts, please take more care when stating your question. Your problem is when running - you said compiling. Also state your error exactly as you get it. If you surround your code with the UBB [code] and [/code] it will preserve the formatting and make it easier to read for those willing to help you.

Jules
vicneswaran boi
Greenhorn

Joined: Sep 06, 2004
Posts: 13
Thank you very much for your help and I will bear your advice in mind
vicneswaran boi
Greenhorn

Joined: Sep 06, 2004
Posts: 13
I did the execute update but i seem to find this error....

incompatible types
found : int
required: java.sql.ResultSet
ResultSet columns = statement.executeUpdate("Delete FROM Member WHERE Pid ="+ id); ^


Thank you in advance
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
you should read the docs first. the method executeUpdate() will return you an int, not a ResultSet. and i think the error would be:

incompatible Datatype
found: ResultSet
required: int
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: delete tag