Solved

Form like WebReport

Posted on 2006-10-25
7
213 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now