Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
Java ComboBox

 
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum
Author Message
diana
Just In
Just In


Joined: 26 Sep 2005
Posts: 1

Post Post subject: Java ComboBox Reply with quote

Hi,
I got a problem.I wan to diaplay all the records of the database to JcomboBox .I used Vector.but the records are not displaying in the jcombobox.It is printing the values in the console. I think the problem is with the line ' itemno=new JComboBox(result);'. I am getting the values from the selectItemID() method.but it is not assigning it to the jcombobox.

The code:-

public Vector selectItemID(){
Vector result = new Vector();

try {
statement = dbConnection.prepareStatement("select ItemId from ItemDetails");
ResultSet itemNumberResult = statement.executeQuery();
while(itemNumberResult.next())
{
String itemNo = itemNumberResult.getString(1);
System.out.println("itemNo " +itemNo);
result.add(itemNo); // add all found itemNos
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;

}


DbActivity dbconnection = new DbActivity();

Vector result= dbconnection.selectItemID();
itemno=new JComboBox(result); // construct Combo with Vector
//System.out.println("Result "+result);

Code:
Wed Sep 28, 05 4:07 am
Back to top
diana View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group