/// <summary>
/// 多表分页
/// </summary>
/// <param name="tblName">主表名</param>
/// <param name="ftblname">从表名</param>
/// <param name="Cfields">从表字段</param>
/// <param name="fldName">主表主键</param>
/// <param name="fldnamefk">主表外键</param>
/// <param name="ftablenamepk">从表主键</param>
/// <param name="PageSize">分页大小</param>
/// <param name="PageIndex">当前页</param>
/// <param name="strOrder">排序方式</param>
/// <param name="strWhere">查询条件</param>
/// <param name="strTerm">主表字段</param>
/// <param name="Count">返回记录的总数</param>
/// <returns></returns>
public static DataSet GetmuchList(string tblName, string ftblname, string Cfields, string fldName, string fldnamefk, string ftablenamepk, int PageSize, int PageIndex, string strOrder, string strWhere, string strTerm, out int Count)
{
SqlParameter[] parameters = {
new SqlParameter("@tblName", SqlDbType.VarChar, 255),
new SqlParameter("@ftblname", SqlDbType.VarChar, 255),
new SqlParameter("@strGetFields", SqlDbType.VarChar, 1000),
new SqlParameter("@fstrfieldes", SqlDbType.VarChar, 1000),
new SqlParameter("@fldName", SqlDbType.VarChar, 255),
new SqlParameter("@fldnamefk", SqlDbType.VarChar, 255),
new SqlParameter("@ftablenamepk", SqlDbType.VarChar, 255),
new SqlParameter("@PageSize", SqlDbType.Int),
new SqlParameter("@PageIndex", SqlDbType.Int),
new SqlParameter("@strOrder", SqlDbType.VarChar,1000),
new SqlParameter("@strWhere", SqlDbType.VarChar,1500),
new SqlParameter("@Count", SqlDbType.Int),
};
parameters[0].Value = tblName;
parameters[1].Value = ftblname;
parameters[2].Value = strTerm;
parameters[3].Value = Cfields;
parameters[4].Value = fldName;
parameters[5].Value = fldnamefk;
parameters[6].Value = ftablenamepk;
parameters[7].Value = PageSize;
parameters[8].Value = PageIndex;
parameters[9].Value = strOrder;
parameters[10].Value = strWhere;
parameters[11].Direction = ParameterDirection.Output;
DataSet ds = SqlConnStr.RunProcedure("pagemuchtable", parameters, "ds");
Count = int.Parse(parameters[11].Value.ToString());
return ds;
}
来源:https://www.cnblogs.com/blogs108/archive/2011/11/03/function.html