日期:2014-05-17 浏览次数:20442 次
//数据库连接字符串(web.config来配置) public static string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; /// <summary> /// 返回分页数据集 /// </summary> /// <param name="storedProcName"></param> /// <param name="parameters"></param> /// <param name="count"></param> /// <returns></returns> public static DataSet RunPageProcedure(string storedProcName, IDataParameter[] parameters, out int count) { using (SqlConnection connection = new SqlConnection(connectionString)) { DataSet dataSet = new DataSet(); connection.Open(); SqlDataAdapter sqlDA = new SqlDataAdapter(); sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters); sqlDA.Fill(dataSet); //dataSet.Tables.RemoveAt(0); count = Convert.ToInt32(sqlDA.SelectCommand.Parameters[7].Value.ToString()); connection.Close(); return dataSet; } } /// <summary> /// 调用分页存储过程 /// </summary> public static DataSet GetList_HL(int iPaging, string TblName, string FldName, int PageSize, int page, string strCondition, string fldSort, out int count) { SqlParameter[] parameters = { new SqlParameter("@iPaging",SqlDbType.Int), new SqlParameter("@TblName",SqlDbType.NVarChar,50), new SqlParameter("@fldName",SqlDbType.NVarChar,4000), new SqlParameter("@PageSize",SqlDbType.Int), new SqlParameter("@page",SqlDbType.Int), new SqlParameter("@strCondition",SqlDbType.NVarChar,2000), new SqlParameter("@fldSort",SqlDbType.NVarChar,500), new SqlParameter("@Counts",SqlDbType.Int) }; parameters[0].Value = iPaging; parameters[1].Value = TblName; parameters[2].Value = FldName; parameters[3].Value = PageSize; parameters[4].Value = page; parameters[5].Value = strCondition; parameters[6].Value = fldSort; parameters[7].Direction = ParameterDirection.Output; return DbHelperSQL.RunPageProcedure("aa_searchdata", parameters, out count); } gvdata.DataSource = DALCommon.GetList_HL(1, "xs_sell", "", pageSize, jsPager.CurrentPageIndex, strp, stro, out count); gvdata.DataBind(); //"xs_sell" 视图名称