Go4Expert (http://www.go4expert.com/)
-   JSP (http://www.go4expert.com/forums/jsp/)
-   -   jsp to Delete data from database wont work (http://www.go4expert.com/forums/jsp-delete-data-database-wont-t24198/)

Dave1816 17Dec2010 12:47

jsp to Delete data from database wont work
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
HTML Code:

<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);





All times are GMT +5.5. The time now is 20:57.