这是鼠标按一个button后执行的代码
table.clearAll();
TableItem t = null;
try{
conn.setAutoCommit(false);
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select sp_code, sp_head from julong_sp_head");
while(rs.next()){
t = new TableItem(table, SWT.NULL);
t.setText(0,rs.getString("sp_code"));
t.setText(1, rs.getString("sp_head"));
}
}catch(Exception ex){
ex.printStackTrace();
}
但是第一次按button是从table的第一行开始填数据的,之后按button,先前的数据确实是被清除掉了,但是并没有从头开始填数据,而是接着原来的最后一行往下填的。
要怎么样写才能从头开始填数据啊?
table.clearAll();
TableItem t = null;
try{
conn.setAutoCommit(false);
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select sp_code, sp_head from julong_sp_head");
while(rs.next()){
t = new TableItem(table, SWT.NULL);
t.setText(0,rs.getString("sp_code"));
t.setText(1, rs.getString("sp_head"));
}
}catch(Exception ex){
ex.printStackTrace();
}
但是第一次按button是从table的第一行开始填数据的,之后按button,先前的数据确实是被清除掉了,但是并没有从头开始填数据,而是接着原来的最后一行往下填的。
要怎么样写才能从头开始填数据啊?
关闭connection ,he resultSet
}这样就可以阿
table.clearAll()只是清除数据,以前的 TableItem没有被移除