Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

getText from ComboBox

combobox

  • Please log in to reply
2 replies to this topic

#1 WingKalimdor

WingKalimdor

    CC Newcomer

  • Just Joined
  • PipPip
  • 13 posts

Posted 05 January 2008 - 04:50 PM

Hello,

I have retrieve the combobox item from my database. But now I having some difficulty to solve price problem. I hope that once I select the item from combobox the price will automatically retrieve from database. Could you teach me how??

Posted Image

Posted Image
  • 0

#2 gszauer

gszauer

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 112 posts

Posted 09 January 2008 - 06:26 PM

Within your database, place a primary key.
This key should auto-increment by one every time a value is inserted.

I am assuming you are using an array/linked list to populate the box.
Create a parallel array/list, and for every title populate it with the movie's primary key number

So, you have the key of each object :)
Lets say "The Golden Compass" is selected, query your database for the primary key, get the primary key, and then look up the price of that key. Does that make sense?
  • 0

It is the mark of an educated mind to entertain a tought without accepting it

If my post was helpful, please help me build some rep Posted Image

#3 WingKalimdor

WingKalimdor

    CC Newcomer

  • Just Joined
  • PipPip
  • 13 posts

Posted 09 January 2008 - 07:21 PM

public void getData(){

String strSelect = "Select * From Product";

try{

stmtSelect = conProduct.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rsProduct = stmtSelect.executeQuery(strSelect);

while(rsProduct.next()){
String ID= rsProduct.getString(2);
jcboItem.addItem(ID);
jtfRDate.setText(var);
if(var==var2)
{

jtfVDate.setText(var2);
}

}

}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"Error");
}
}
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download