存储过程代码
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[GetAllPhone]
(@brand1 NVarChar(200),@startIndex int,
@endIndex int)
asbegin
with temptbl as (
SELECT ROW_NUMBER() OVER (ORDER BY ID desc)AS Row, * from PhoneInfo where Brand=@brand1)
SELECT * FROM temptbl where Row between @startIndex and @endIndex
end后台调用代码: private void Loaddata(string a)
{
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter("@startIndex", SqlDbType.Int),
new SqlParameter("@brand1", SqlDbType.NVarChar),
new SqlParameter("@endIndex ",SqlDbType.Int)};
parms[0].Value = AspNetPager1.StartRecordIndex;
parms[1].Value = a;//这里parms[1].Value 这个给个什么字符串可以获得所有数据表中的数据
parms[2].Value = AspNetPager1.EndRecordIndex;
Repeater1.DataSource = DbHelperSQL.RunProcedure("GetAllPhone", parms, "PhoneInfo").Tables["PhoneInfo"].DefaultView;
Repeater1.DataBind();
}
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[GetAllPhone]
(@brand1 NVarChar(200),@startIndex int,
@endIndex int)
asbegin
with temptbl as (
SELECT ROW_NUMBER() OVER (ORDER BY ID desc)AS Row, * from PhoneInfo where Brand=@brand1)
SELECT * FROM temptbl where Row between @startIndex and @endIndex
end后台调用代码: private void Loaddata(string a)
{
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter("@startIndex", SqlDbType.Int),
new SqlParameter("@brand1", SqlDbType.NVarChar),
new SqlParameter("@endIndex ",SqlDbType.Int)};
parms[0].Value = AspNetPager1.StartRecordIndex;
parms[1].Value = a;//这里parms[1].Value 这个给个什么字符串可以获得所有数据表中的数据
parms[2].Value = AspNetPager1.EndRecordIndex;
Repeater1.DataSource = DbHelperSQL.RunProcedure("GetAllPhone", parms, "PhoneInfo").Tables["PhoneInfo"].DefaultView;
Repeater1.DataBind();
}
parms[2].Value = AspNetPager1.EndRecordIndex-1;
或者
parms[1].Value = 1;
parms[2].Value = AspNetPager1.EndRecordIndex;没有试过,自己试试
parms[1].Value="1 or 1=1";parms[1].Value
这样就OK了
SELECT ROW_NUMBER() OVER (ORDER BY ID desc)AS Row, *
from PhoneInfo where Brand=@brand1
) a
where Row between @startIndex and @endIndex