"@P0"是第一个参数有问题,第二个参数有问题则是"@P1"
注:使用sqlserver进行查询操作时,Top后面是不允许使用?占位符.
例如:
//定义sql语句:select top 2* from news where ntid=14 order by ncreateDate DESC String sql="select top "+limit+"* from news where ntid=? order by ncreateDate DESC";
例 2:
/* select top 5 * from news where Nid not in (select top 10 Nid from news order by NCreateDate desc) order by NCreateDate desc */ String sql="select top "+pageSize+" * from news\r\n"+ "where Nid not in (select top "+(currPageNo-1)*pageSize+" Nid from news order by NCreateDate desc)\r\n"+ "order by NCreateDate desc";