Solved

Form like WebReport

Posted on 2006-10-25
7
223 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
Industry Leaders: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
getting param value 7 62
project group option in netbeans equivalent term in eclipse 1 61
best way to search/remove a file from an EAR file 3 119
withoutString  challenge 40 224
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
Deploying our service is a grudge match between customer benefits and customer pain. In one corner, rolling out fixes (yay!) and delivering new features (double yay!). In the other corner, training on new features (boo – sounds like work), and chan…
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…
Suggested Courses

751 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