关于数据库分页的搜索条件问题????
create proc getMemberList
@viewTable varchar(50),--要显示的表或视图
@sqlString varchar(300), --查询语句
@viewField varchar(200),--字段(多个用正中逗号隔开)
@pagesize int, --每页大小
@showPage int --当前页
As
declare @jilu bigint
set @showPage=@showPage-1
set @jilu=@pagesize*@showPage
if (@viewField= ' ')
begin
set @viewField= '* '
end
declare @sql nvarchar(200)
set @sql=N 'select top '+convert(varchar(10),@pagesize)+ ' '+convert(varchar(200),@viewField)+ ' from '+convert(varchar(50),@viewTable)
set @sql=@sql+ ' where id not in (select top ' +convert(varchar(10),@jilu)+ ' id from '+convert(varchar(50),@viewTable)+ ' where 1=1 '+@sqlString+ ' order by id) ' +@sqlString+ ' order by id '
exec sp_executesql @sql
return
public DataTable GetMemberList(string viewTable,string sqlString,string viewField,int pageSize,int showPage)
{
DataTable ds = new DataTable();
SqlConnection conn = null;