I have an MS Access database, in which there is a set of tablet names in column name ‘tname’. I have 5 comboboxes in java applet. All the 5 comboboxes must update the items in tname, each time when it loads. I used the following code. It adds only the first item in tname to the first combobox only. Other boxes remain empty. But if I update a single combobox, it works. But I need 5 comboboxes to get updated. Kindly guide me through the problem I’ve made.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn9=DriverManager.getConnection("jdbc:odbc:vasantham","","");
Statement st9=conn9.createStatement();
ResultSet rs9=st9.executeQuery("select DISTINCT tname from try");
while(rs9.next())
{
ct19.addItem(rs9.getString("tname"));
ct29.addItem(rs9.getString("tname"));
ct39.addItem(rs9.getString("tname"));
ct49.addItem(rs9.getString("tname"));
ct59.addItem(rs9.getString("tname"));
}
conn9.close();
}
I have tried, it works all fine as i was wondering what is the need to have a
tempvariable look at my code, its fully working codeit populates cboxes with all rows in table