小森
发贴: 1
积分: 0
|
于 2008-07-16 01:57
String cardID = new String(); String computerID = new String(); String beginTime = new String(); String endTime = new String(); String balance = new String(); String str1 = new String(); String str2 = new String(); int fee = 0;
try { Statement stmtObj = Connect.getStatement(); ResultSet rs = stmtObj.executeQuery("select top 1 * from Record order by ID desc"); if (rs.next()) { cardID = rs.getString(2); computerID = rs.getString(3); beginTime = rs.getString(4); endTime = rs.getString(5); } //计算费用 fee = Account.calFee(beginTime, endTime); str1 = "update Card set Balance = Balance - " + fee + "where ID like '" + cardID + "'"; stmtObj.executeUpdate(str1);
str2 = "select Balance from Card where ID like '" + cardID + "'"; rs = stmtObj.executeQuery(str2); balance = String.valueOf(rs.getInt(1));
ComputerID.setText(computerID); CardID.setText(cardID); BeginTime.setText(beginTime); EndTime.setText(endTime); Consume.setText(String.valueOf(fee)); Balance.setText(balance);
} catch (Exception e) { System.out.println; }
这段代码是网吧管理系统里面的参与计费的部分代码...我把这段代码放在panel的主类里面.既当加载这个面板的时候则开始执行这段代码...想问下为什么当我运行到以上代码后...会显示出j<ava.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态>...希望有高人能指点下我
|