谁知道 DataExpress 中的 Database 在配置好链接的情况下
如何 与已知字段比较 是不是 这样啊?
database1 为 拉过的来的database 控件 database1.openConnection();
database1.createStatement();
int i=database1.executeStatement("select * from users where id=1");
if (i!=0) {
this.jLabel1.setText("ok"+ i);
}
database1.closeConnection(); 注:database1 控件在测试时候可以连接数据库这样又给我爆错了:
Exception in thread "AWT-EventQueue-0" See com.borland.dx.dataset.DataSetException error code: BASE+66
com.borland.dx.dataset.DataSetException: Can not issue SELECT via executeUpdate().
at com.borland.dx.dataset.DataSetException.a(Unknown Source)
at com.borland.dx.dataset.DataSetException.throwException(Unknown Source)
at com.borland.dx.dataset.DataSetException.SQLException(Unknown Source)
at com.borland.dx.sql.dataset.Database.executeStatement(Unknown Source)
如何 与已知字段比较 是不是 这样啊?
database1 为 拉过的来的database 控件 database1.openConnection();
database1.createStatement();
int i=database1.executeStatement("select * from users where id=1");
if (i!=0) {
this.jLabel1.setText("ok"+ i);
}
database1.closeConnection(); 注:database1 控件在测试时候可以连接数据库这样又给我爆错了:
Exception in thread "AWT-EventQueue-0" See com.borland.dx.dataset.DataSetException error code: BASE+66
com.borland.dx.dataset.DataSetException: Can not issue SELECT via executeUpdate().
at com.borland.dx.dataset.DataSetException.a(Unknown Source)
at com.borland.dx.dataset.DataSetException.throwException(Unknown Source)
at com.borland.dx.dataset.DataSetException.SQLException(Unknown Source)
at com.borland.dx.sql.dataset.Database.executeStatement(Unknown Source)
不能执行 select 语句应该有
executeQuery()吧!
你的思路有问题,你的SQL是查询对象,而你要的是对象是否存在。你应该用ResultSet rs =database1.executeQuery("select * from users where id=1");
if(rs.next()){
... 具体的代码你自己修改吧。包括那个ResultSet 类1