Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

delete tag

 
vicneswaran boi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your help and I will bear your advice in mind
 
vicneswaran boi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic