jsp to Delete data from database wont work

Discussion in 'JSP' started by Dave1816, Dec 17, 2010.

  1. Dave1816

    Dave1816 New Member

    Dec 17, 2010
    Likes Received:
    Trophy Points:
    Hello can im new to Jsp and trying to delete data in a database using JSP. everything works fine except the data dose not delete :nonod: I have posted the code below if any 1 can help me. Thanks
    <title>Delete Question
    int nID1;
     if (request.getParameter("nID") == null) {
    } else {
     String sQuestID = request.getParameter("nID"); 
     nID1 =  Integer.parseInt(sQuestID);
    <!-- the % tag below is what is called a scriptlet tag - allows java to be embedded in the jsp -->
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
    // creates and initialises the JDBC-ODBC bridge driver
    	// NB this driver is designated as "experimental" and not recommended for commercial use!
    	// note that we give the name of the local directory here! --> "nas1/" segment below
    	// will need changing if this page is moved!
    	String sHere = getServletContext().getRealPath("/au003022/jsp/bare2/JSP-FAQ-assignment.accdb");
    	// builds the connection string - makes it easier to print it for checking purposes
    	String sConn = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + sHere + ";";
    // makes the connection with the database
    	Connection cnJDBC = DriverManager.getConnection(sConn);
    	// gets ready to send a SQL command down our connection
    	Statement stJDBC = cnJDBC.createStatement();
    	// Allows us to check our SQL statement and see that it is well formed
    	String sSQL = "Delete FROM tblFAQ WHERE ID='" + nID1 + "';";	
    	//out.print("Debug:<br />" + sSQL + "<hr />");
    //ResultSet rs = stJDBC.executeUpdate(sSQL);
    Last edited by a moderator: Dec 19, 2010

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice