我有一種從數據庫中填充組合框的方法。它使用醫生ID來填充它。問題是,當我將ID更改爲另一個人而不是清除組合框然後重新填充它時,它只是添加到列表的末尾。從組合框中刪除項目
public void FillTimings() {
theapptTime.removeAllItems();
theapptTime.repaint();
String strDate = theTdate.getText().trim();
String strDoctor = (String) theTstaffname.getSelectedItem();
System.out.println(strDoctor);
try {
db.dbConnect();
String docId = db.getdociD(strDoctor);
ResultSet rs = db.getTimings(strDate, docId);
while (rs.next()) {
theapptTime.addItem(rs.getString(1));
rs.close();
}
} catch (SQLException e1) {
System.out.println("fail");
e1.printStackTrace();
}
}
這是代碼。
有人可以幫助我。
這將是有益的,如果你想補充一個標籤的編程語言。這可能引起合適人士的關注。 – DOK 2012-04-08 17:38:45
看看這個鏈接:http://support.microsoft.com/kb/319927 – 2012-04-08 17:45:45
爲了更好地幫助,請發佈[SSCCE](http://sscce.org/)。 但正如文件中提到的那樣,將D/B和因子硬編碼一些數據。 – 2012-04-08 18:06:37