注:com.microsoft.sqlserver.jdbc.SQLServerException: “@P0”附近有语法错误。

2022/3/19 19:28:38

本文主要是介绍注:com.microsoft.sqlserver.jdbc.SQLServerException: “@P0”附近有语法错误。,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

"@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";



这篇关于注:com.microsoft.sqlserver.jdbc.SQLServerException: “@P0”附近有语法错误。的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程