Solved

Form like WebReport

Posted on 2006-10-25
7
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This article is written by John Gates, CISSP. Gates, the SNUG President-Elect, currently holds the position of Manager of Information Systems at Lake Park High School in Roselle, Illinois.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

626 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