aspnet调用mysql存储过程

public static DataTable CommonPagenation(string tableName,string selectWhere,string selectID,string selectOrder,int pageNo,int pageSize,out int totalcount,out int pagecount)
{
DataTable reuslt = new DataTable();

using (MySqlConnection conn = new MySqlConnection(connectionString))
{
if (conn.State == ConnectionState.Closed)
conn.Open();

MySqlDataAdapter sda = new MySqlDataAdapter("CommonPagenation", conn);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
MySqlParameter[] param = new MySqlParameter[8];
param[0] = new MySqlParameter("?tableName", tableName);
param[1] = new MySqlParameter("?selectWhere", selectWhere);
param[2] = new MySqlParameter("?selectID", selectID);
param[3] = new MySqlParameter("?selectOrder", selectOrder);
param[4] = new MySqlParameter("?pageNo", pageNo);
param[5] = new MySqlParameter("?pageSize", pageSize);
param[6] = new MySqlParameter("?_totalcount",MySqlDbType.Int32);
param[6].Direction = ParameterDirection.Output;
param[7] = new MySqlParameter("?_pagecount", MySqlDbType.Int32);
param[7].Direction = ParameterDirection.Output;
sda.SelectCommand.Parameters.AddRange(param);
sda.Fill(reuslt);
totalcount = Convert.ToInt32(param[6].Value);
pagecount = Convert.ToInt32(param[7].Value);

}
return reuslt;

}

前台我是用的aspnetpager,非常好用的分页工具

 <webdiyer:AspNetPager ID="ItemPaging" runat="server" 
                CustomInfoSectionWidth="30%" PageSize="20" FirstPageText="首页" 
                LastPageText="最后一页" NextPageText="下一页" PrevPageText="上一页" 
                ShowCustomInfoSection="Left" CenterCurrentPageButton="True" LayoutType="Table" 
                ShowPageIndexBox="Never" OnPageChanging="ItemPaging_PageChanging">
            </webdiyer:AspNetPager>

调用::

DataTable table = DbHelperMySql.CommonPagenation("dede_archives", " typeid="+typeid, "", " dates desc ", ItemPaging.CurrentPageIndex, ItemPaging.PageSize,out totalcount,out pagecount);
            ItemPaging.RecordCount = totalcount;
            ItemPaging.AlwaysShow = true;
            ItemPaging.CustomInfoHTML = "总计<font color='blue'><b>" + ItemPaging.RecordCount.ToString() + "</b></font>条,";
            ItemPaging.CustomInfoHTML += "当前为第<font color='red'><b>" + ItemPaging.CurrentPageIndex.ToString() + "</b></font>页,";
            ItemPaging.CustomInfoHTML += "共<font color='blue'><b>" + ItemPaging.PageCount.ToString() + "</b></font>页";



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值