******** post by prabhat*********for database updation
the relation table is" test(roll(int),sub_code(int),stud_name(varchar),su b_name(varchar),fees(money),status(bit)
*********
basic prob is that when updation is done the form keeps the prevoius values of updation and that leads to incosistent results..........

HTML Code:
<%@ page import="java.sql.*"%>
<html>

<head><title>table update test</title></head>
<body>
<form name="f1">

<%
	

int id=0;


Connection con = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER;user=sa;password=password@123");
	
	Statement stmt=con.createStatement();

// for test table update 	  

    int id1=0;
    float id2=0;
	String st=request.getParameter("cmbroll");
	String st1=request.getParameter("txtsub_code");
	String st2=request.getParameter("txtstud_name");
	String st3=request.getParameter("txtsub_name");
	String st4=request.getParameter("txtfees");
	boolean st5=Boolean.parseBoolean(request.getParameter("txtstatus"));

	if(st!=null)
	{
   		id=Integer.parseInt(st);
	} 
	 
	if(st1!=null)
	{
	  id1=Integer.parseInt(st1);
	}
	
	if(st4!=null)
	{
		id2=Float.parseFloat(st4);
	}
	
	
	  
	
%>

<h2>roll<sup>*</sup><select name="cmbroll" onChange="document.f1.submit()"></h2>
<option>select</option>
 <%
 ResultSet rs=stmt.executeQuery("select roll from test ");
 	while(rs.next())
 	{
 	
 		int x=rs.getInt("roll");
 	
 	
  %>
<option
<% if(id!=0 && id==x) 
out.println("selected");
 %>

>


<%= x %></option>

<% 

} 

%>  
</select>

 <% 
 
 
 	
 	if(id!=0)
 	{ 
 	
 		ResultSet rs1=stmt.executeQuery("select * from test where roll="+id);
 		while(rs1.next())
 		{
 			 int code=rs1.getInt("sub_code");
 			 String sname=rs1.getString("stud_name");
 			 String sbname=rs1.getString("sub_name");
 			 float fss=rs1.getFloat("fees");
 			 boolean sts=rs1.getBoolean("status");



 			 
 	
 	
  %>
   
  
  <h2>Subject Code<input type="text" name="txtsub_code" value="<%=code%>"></h2>
  <h2>Student Name<input type="text" name="txtstud_name" value="<%=sname%>"></h2>
  <h2>Subject Name<input type="text" name="txtsub_name" value="<%=sbname%>"></h2>
  <h2>Fees<input type="text" name="txtfees" value="<%=fss%>"></h2>
  <h2>Status<input type="text" name="txtstatus" value="<%=sts%>"></h2>
  <input type="submit" value="update">
  
  <% 
   	  }
		  if(st1!=null && id1!=0 && st3!=null && id2!=0)
		  stmt.executeUpdate("update test set sub_code="+id1+",stud_name='"+st2+"',sub_name='"+st3+"',fees="+id2+",status='"+st5+"' where roll="+id);

  }
  
 
 
 %>
 
 </form>
 </body>
 </html>
looking forard for your response......
thanks .........
prabhat....

Last edited by shabbir; 23Mar2008 at 13:27.. Reason: Code block