public ResultSet getData(String tablename,String condition,int pagesize,int currentpage)
{//分页送显数据的方法
try
{
String sql = "";
sql = "select top "+pagesize+" * from "+tablename+
" where id not in(select top "+pagesize*(currentpage-1)+
" id from "+tablename+" where 1=1 "+
(condition==""?"":(" and "+condition))+")"+(condition==""?"":(" and "+condition));
stat = con.createStatement();
rs = stat.executeQuery(sql);
}
catch(Exception e){
System.out.println(rs);
System.out.println("查询失败dbcon");
}
return rs;
}
为啥rs返回null啊 谢谢了
{//分页送显数据的方法
try
{
String sql = "";
sql = "select top "+pagesize+" * from "+tablename+
" where id not in(select top "+pagesize*(currentpage-1)+
" id from "+tablename+" where 1=1 "+
(condition==""?"":(" and "+condition))+")"+(condition==""?"":(" and "+condition));
stat = con.createStatement();
rs = stat.executeQuery(sql);
}
catch(Exception e){
System.out.println(rs);
System.out.println("查询失败dbcon");
}
return rs;
}
为啥rs返回null啊 谢谢了
看看sql能执行出结果么?
这类问题一般都是由于粗心导致的小问题。
select top 100 * from ryb where id not in(select top 0 id from ryb where 1=1 and user='' and password='') and username='' and password=''
有点意思。
select top 100 * from ryb where id not in(select top 0 id from ryb where 1=1 and user='' and password='') and username='' and password=''在sqlserver中将参数带进去看看有没有数据。。我忘记top从0还是1开始的了
"select *,row_number() over(order by qs_code) rn "+
"from TEST.QS) a where rn between ? and ?";
teacher ----- ryb