<%@ page import="java.sql.*"%>
<html>
<body bgcolor="pink">

<%
String user=request.getParameter("us");
String pass=request.getParameter("pa");
String a=request.getParameter("na");
String a1=request.getParameter("no");
String a2=request.getParameter("el");

Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("Jdbc:Odbc:Data405");
stmt=con.createStatement( );
stmt.executeUpdate("Insert Into stud(username,password,nam,nos,elg) 

Values('"+user+"','"+pass+"','"+a+"','"+a1+"','"+a2+"')");
  
out.println("File inserted");
}
catch(Exception e)
{
out.println("error");
}
con.close();
%>
<a href="http://localhost:8080/maya/login1.jsp">go back</a>  
</body>
</html>

I can display the details but can't insert through code.

Recommended Answers

All 4 Replies

It might help to know what the error is. Also, many times, you have to actually close the connection to access before changes are committed. Acess is really not suited to any kind of web application.

Also, you really need to remove these scriptlets from your JSP. Scriptlets are extremely discouraged these days and are only still allowed to keep from breaking backwards compatability. Create some beans and/or other application services.

Than you.But I got another insertion pgm using this same code

And?

So, in other words, you don't want any advice you simply want to here us say "Your code is perfect and it should work, something else about the system is torqued." Well, okay, now you've heard it, believe what you will.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.