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
Solved

Form like WebReport

Posted on 2006-10-25
7
219 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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