Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载萛uFFFD\uFFFD?绦蚶啾\uFFFD
Connection con = DriverManager.getConnection("jdbc:odbc:myodbc"); //驱动
//链接
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
String sql = "select * from logininfo where username='" + id + "' and password=" + pwd +
"";
System.out.println(sql);
ResultSet rs = stmt.executeQuery(sql); //建立ResultSet(结果集)对象,并执行SQL覾uFFFD\uFFFD
if (!rs.next()) {
System.out.println("not found");
rs.close();
stmt.close();
con.close();
return;
}
System.out.println("ok");
rs.close();
sql = "insert into loginlog (username, logintime) values (" + id + ", '" + (new java.util.Date().toString()) + "')";
stmt.executeUpdate(sql);
stmt.close();
con.close();
this.hide();
Dialog1 d = new Dialog1(this, "", true);
d.frame1 = this;
d.id = id;
d.pwd = pwd;
d.queryDataSet1.closeStatement();
d.queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
d.database1,
"SELECT * from loginlog where username=" + id, null, true, Load.ALL));
d.queryDataSet1.open();
d.show();
this.show();
} catch (Exception ex) {
ex.printStackTrace();
}
}
用的是access2003做数据库 但是现在只能显示ID和登录时间 我要怎么改才可以增加显示部gate和性别等选项? 应该修改哪里啊? 达人指教~
[ 此贴被不想飞的鱼在2007-06-03 11:03重新编辑 ]