Solved

Form like WebReport

Posted on 2006-10-25
7
217 Views
Last Modified: 2010-08-05
Hi

I am working on webreport that will display data pulling data from database below is the code.
When data is displayed on web it should display in form format so that it can be updated by user.
It is not just a report but its a form based report

<TABLE WIDTH="100%" BORDER="+5" >
    <TR > <h5>
    <%
    for(int i = 1 ; i <= rsmd.getColumnCount() ; i++) {
    %> </h5>
    <TH>
    <%= rsmd.getColumnLabel(i) %>
    </TH>
    <% } %>
    </TR>  
<% while(rs.next()) { %>  
<form method=post action = saveForm()>
<input type=text value = rs.getString(1)>
<input type=text value = rs.getString(2)>
<input type=text value = rs.getString(3)>
<input type=submit name=save>
</form>
   <% } %>    

I am want to something like above code where data will be displayed in text boxes so that user can update records.
I am not sure how to do it. Can anyone post sample code which have functionality for similar requirement.
Please give me sorce code that will explain me what exactly what I can do.

Thanks
0
Comment
Question by:basirana
  • 4
  • 3
7 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 17806261
what error are you getting in above code?
0
 

Author Comment

by:basirana
ID: 17806695
I am not getting any error I have given same code. I am looking for sample code that fits into requirement
0
 
LVL 10

Accepted Solution

by:
jaggernat earned 500 total points
ID: 17807400
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:basirana
ID: 17808529
Please check below code something similar that wouls help me to update the values

<%@ page import="java.sql.*"%>
<%
            Connection con=null;
            Statement st=null;
%>
<%
            DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
            con=DriverManager.getConnection("jdbc:odbc:emp");
            st=con.createStatement();
%>

<html>
<head><title>:: Display ::</title></head>
<body bgcolor=goldenrod>
<form method=get name=display action="udate.jsp" >
      <center><h1>Update</h1></center>
      <br>
      <hr>
      <br>
      <%@ include file="conn.jsp" %>
      <%
      try
        {       
            int nus = Integer.parseInt(request.getParameter("no"));
            ResultSet rs = st.executeQuery("select * from emp where empno="+nus+"");
      if(rs.next())
      {%>
      <table bgcolor=khaki border=1 align=center>
      <tr><th bgcolor=seablue>Emp ID</th><td bgcolor=silver><input type=text name=id value=<%= rs.getInt(1) %>></td></tr>
      <tr><th bgcolor=seablue>Emp Name</th><td bgcolor=silver><input type=text name=name value=<%= rs.getString(2)%>></td></tr>
      <tr><th bgcolor=seablue>Emp Salary</th><td bgcolor=silver><input type=text name=sal value=<%= rs.getInt(3)%>></td></tr>
      <tr><th bgcolor=seablue></th><td bgcolor=silver><input type=submit value=Update name=opt><input type=submit value=Delete name=opt></td></tr>
      </table>
      <%}      
      }catch(Exception e){e.toString();}
      %>
      
</form>      
</body>
</html>
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17808575
>>>>select * from emp where empno="+nus+"");

the above query would retrieve the records from database. For update you would need "update"  query.

see this

http://java.sun.com/docs/books/tutorial/jdbc/basics/updating.html
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17808584
and if you want to retrieve records using "select" query this would help

http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html
0
 

Author Comment

by:basirana
ID: 17811228
I am sorry I think question was not clear. I am looking for example that will help me to display records from database inform of rows. I am able to display the data in tablular format. but I have some columns that will be displaying textboxs so that user can updates the records when diplayed.

example

EMPNO                     EMPNAME                DOB
123                         _________              ________
1234                       _________              ________
236                         _________              ________

_______ are nothing but textboxs

Syntax:
<tr><td>rs.getString(empno)</td>  <td><input type="text" value=rs.getstring(empname)></td> ....</tr>
<tr><td>rs.getString(empno)</td>  <td><input type="text" value=rs.getstring(empname)></td> ....</tr>
<tr><td>rs.getString(empno)</td>  <td><input type="text" value=rs.getstring(empname)></td> ....</tr>

this will help in getting empname from user as input value.
So that webreport will be something like grid format with textboxs for input so that user can update information when it is dislayed.
As multiple records are displayed it should update multiple records when user clicks on update.
I am looking for good example..

Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The question appears often enough, how do I transfer my data from my old server to the new server while preserving file shares, share permissions, and NTFS permisions.  Here are my tips for handling such a transfer.
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question