开发者

get data from a Db display in combobox in java

hi everyone i have this code but don't know why it doesn't work!开发者_Go百科

rset = stmt.executeQuery("SELECT categoryName FROM DB_Library.dbo.categories");
while (rset.next()) {
    String s = rset.getString("categoryName");
    jComboBox1.addItem(rset.getString(s).trim());
}

don't show me any thing * This code is printing all the items in database:

rset = stmt.executeQuery("select * from DB_Library.dbo.categories");
while (rset.next()) {
    String s = rset.getString("categoryName");
    System.out.println(s );
}

any help?


Try the following:

rset = stmt.executeQuery("SELECT categoryName FROM DB_Library.dbo.categories");
while (rset.next())
{
    String s = rset.getString("categoryName");
    jComboBox1.addItem(s.trim());
}


The combobox items must be loaded before it is painted in the screen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜