sql语句@参数位置,@参数放在 top后面不行吗?老是报,@maximumRows和@startRowIndex有错?
string sql = "select top @maximumRows * from T_Person where Id>(select isnull(MAX(Id),0) from (select top @startRowIndex Id from T_Person order by Id) as Temp) order by Id"
下面是adapter加参数的过程,
SqlConnection conn = new SqlConnection(consql);
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
adapter.SelectCommand.Parameters.Add(new SqlParameter("maximumRows",maximumRows));
adapter.SelectCommand.Parameters.Add(new SqlParameter("startRowIndex",startRowIndex));
DataTable dt = new DataTable();
adapter.Fill(dt);
return dt;
------解决方案--------------------
string sql = "select top @maximumRows * from T_Person where Id>(select isnull(MAX(Id),0) from (select top @startRowIndex Id from T_Person order by Id) as Temp) order by Id"
  top @startRowIndex 改为  top (@startRowIndex)  就可以了