Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-16-2009, 07:40 AM   PM User | #1
rajaramesh
New to the CF scene

 
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
rajaramesh is an unknown quantity at this point
Combobox value returns "Null"

Hi friends,

I want to display a field value in combo box from database.
But the result, it returns me null in combo box, even in textbox also..

Plz help me in this regard.
Advance thanks to u all.

Code:
<%@ page import="java.sql.*" %>
<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %>
<HTML>
    <HEAD>
        <TITLE>Database</TITLE>
    </HEAD>

    <BODY>
        <H1>Database</H1>
        <% 
            Connection connection = DriverManager.getConnection("jdbc:odbc:emaildb", "", "");
            Statement statement = connection.createStatement();
            String Cname = request.getParameter("CompName");
             String Fy = request.getParameter("FYear");
              String Qtr = request.getParameter("Quarter");
               String QtrAm = request.getParameter("QtrAmt");  
          ResultSet resultset = statement.executeQuery("select CompanyName, sum(ForQtr)as Tota from Imports group by CompanyName") ;
                 
          
            if(!resultset.next()) {
            out.println("Sorry, could not find that CompInfo. ");
            } else {
        %>
        	<TABLE BORDER="1">
            <TR>
              
           <!--<TH>Financial Year</TH>
           <TH>Sum of Quarters</TH>-->
           </TR>
            <% String AB=request.getParameter("CompanyName");%>
     		<input type="text" value="<%=AB%>">   
           
           <select>
           <%
           while(resultset.next()) {
           String ABC=request.getParameter("CompanyName");
            out.print("<option>"+ABC+"</option>");
           
           %>
           </select>
           <TR>
               <TD> <%= resultset.getString(1) %> </TD>
               <TD> <%= resultset.getString(2) %> </TD>
              
          </TR>
      
       <%}%>
                    
       </TABLE>
          
       
       <BR>
      
           
       <% 
           } 
       %>
    </BODY>
</HTML>
regards
raja
rajaramesh is offline   Reply With Quote
Old 03-20-2009, 06:31 PM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
you need to name ur form elements otherwise how can the application server distinguish one textbox from another? same goes for the selects too...
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Reply

Bookmarks

Tags
combo box, null, return

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:55 PM.


Advertisement
Log in to turn off these ads.