Topic: 怎么逐条的读取SQL表中的记录放到文本框中?(高手请进!)

  Print this page

1.怎么逐条的读取SQL表中的记录放到文本框中?(高手请进!) Copy to clipboard
Posted by: q_yuan
Posted on: 2005-10-06 23:33

我做了一个界面,界面上有几个文本框(text_ID,text_Name,text_Sex,text_Address等)和一个Next按钮,还有一个SQL Server的表内容有相应的字段(ID,Name,Sex,Address等),我想用Next按钮来逐条的读取SQL表中的记录并用文本框显示。我用了if(rs.netx()),就只能显示第一条,用while(rs.next())就只能显示最后一条,不能实现逐条的读取SQL表中的记录,要怎么办?请教高手了!
我的一部分代码如下:
i=1;
   public void showContent(){     
     try{
  if(rs.absoluteLight Bulb){
      text_Id.setText(rs.getString("ID"));
      text_Name.setText(rs.getString("T_Name"));
      text_Sex.setText(rs.getString("Sex"));
      text_Birthday.setText(rs.getString("Bthirday"));
      text_Password.setText(rs.getString("Password"));
      text_Address.setText(rs.getString("Address"));
      text_Bak.setText(rs.getString("Bak"));
     }
     }catch(Exception ex){}
     
   }
   public void bnt_NextActionPerformed(ActionEvent evt){
try{
showContent();
}catch(Exception ex){ex.getMessage();}
i++;
}

2.Re:怎么逐条的读取SQL表中的记录放到文本框中?(高手请进!) [Re: q_yuan] Copy to clipboard
Posted by: chenjianguojt
Posted on: 2005-10-19 23:54

你可以将读出的数据先存放在一个collection中,比如ArrayList;然后可以通过为next按钮设置监听器来将存下的记录一条条在文本框中显示出来


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923