assigning the variable to textfeild

Discussion in 'JSP' started by qurratulain, Jan 13, 2007.

  1. qurratulain

    qurratulain New Member

    Joined:
    Oct 16, 2006
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    sir
    i trying to update the recin the database .jsp page fetches the data from the databse .and place the data in to the text feild . im trying to genrate the the registration no in the text feild automatically. with code given below but it is not working well,

    i m using the code
    Code:
    <%@page import="java.sql.*"%>
    	<body>
    
    		<%
    	
    		
    		
    
    	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    
    	Connection con=DriverManager.getConnection("jdbc:odbc:school-db");
    
    	Statement stat=con.createStatement();
    
    	ResultSet rs=stat.executeQuery("SELECT COUNT(SID_GR) from Std-Info");
    		
    		while(rs.next()){
    				
    				String regno=rs.getString(1);
    				
    				if(regno.equals("")){
    				
    					regno=("SOE-"+0001);
    
    						}
    				
    				else {
    					
    					
    				regno=("SOE-"+0000+regno);
    
    					}
    				}
    
    		String regno="SOE-0001";
    	%>
    
    
    
    
    
    
    
    
    
    <html>
    <head>
    
    <title>home page of school</title>
    <style type="text/css" media="all">
    
    </style>
    <link rel="stylesheet" type="text/css" href="styles.css" media="all" />
    <LINK href="style.css" type=text/css rel=stylesheet>
    </head>
    <body>
            <TR>
              <TD class=infoboxcolumn width="15%" height=25>NAME:</TD>
              <TD borderColor=#dddddd width="35%" height=25><INPUT  name="ID"     value=\"<% regno %>\"></TD></tr>//error is here
    
             <tr> <TD >PASSWORD:</TD>
              <TD ><INPUT  type="password" name="Pass" value="pass"></TD></TR>
    		
           
        </TABLE><BR>
    
    		</CENTER>
    				
    </form>
    </body>
    
    <br/><br/> </html>
    
    
    
    
    
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    That's very easy..

    Code:
    <INPUT  name="ID"  value="<%=regno %>">
    Happy Coding!
     

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