存储过程分页,出错!为什么?

wtle wtle 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

C#:
private void bind(int PageIndex)
{
string sql = "flag='0'";
int PageSize = Convert.ToInt16(DBConfig.PageSize);
DataSet ds = new DataSet();
DB.OpenConnection();
SqlCommand cmd = new SqlCommand("sp_All_Pager2", DBConfig.cn);
cmd.CommandType = CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(cmd);
cmd.Parameters["@tblName"].Value = "HR";
cmd.Parameters["@fldNames"].Value = "id,name";
cmd.Parameters["@fldNames2"].Value = "(SELECT pid FROM HR2 WHERE (HRid = tmpTable.id)) AS pid";
cmd.Parameters["@fldOrderName"].Value = "id";
cmd.Parameters["@orderType"].Value = 0;
cmd.Parameters["@PageIndex"].Value = PageIndex;
cmd.Parameters["@PageSize"].Value = PageSize;
cmd.Parameters["@strWhere"].Value = sql;
cmd.Parameters["@totalCount"].Direction = ParameterDirection.Output;
SqlDataAdapter dp = new SqlDataAdapter();
dp.SelectCommand = cmd;
dp.Fill(ds, "hrdocmi");
int PageCount;
int RecordCount = Convert.ToInt32(cmd.Parameters["@totalCount"].Value);
if (RecordCount == 0)
{
PageCount = 1;
}
else
{
if (RecordCount % PageSize == 0)
PageCount = RecordCount / PageSize;
else
PageCount = RecordCount / PageSize + 1;
}
this.PageNavigator1.PageCount = PageCount;
this.PageNavigator1.PageIndex = PageIndex;
this.PageNavigator1.RecordCount = RecordCount;
Repeater1.DataSource = ds.Tables[0];
Repeater1.DataBind();
ds.Clear();
dp.Dispose();
DB.CloseConnection();
}
...全文
评论 2
收藏 已收藏
分享
返回顶部
wtle
.NET社区 62,271 成员 668,968 内容