0
<%@ 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.

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by masijade
0

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.

Edited by masijade: n/a

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.