日期:2014-05-18 浏览次数:20539 次
public List<LinkModel> GetList(string tblName, string FieldKey, int PageCurrent, int PageSize, string FieldShow, string FieldOrder, string where, out int pageCount) { List<LinkModel> linkList = new List<LinkModel>(); SqlDataReader dr = default(SqlDataReader); SqlParameter[] parameters = { new SqlParameter("@tbname", SqlDbType.VarChar, 255), new SqlParameter("@FieldKey", SqlDbType.NVarChar,1000), new SqlParameter("@PageCurrent", SqlDbType.Int), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@FieldShow", SqlDbType.NVarChar,1000), new SqlParameter("@FieldOrder", SqlDbType.NVarChar,1000), new SqlParameter("@Where", SqlDbType.VarChar,1000), new SqlParameter("@RowCount", SqlDbType.Int) }; parameters[0].Value = tblName; parameters[1].Value = FieldKey; parameters[2].Value = PageCurrent; parameters[3].Value = PageSize; parameters[4].Value = FieldShow; parameters[5].Value = FieldOrder; parameters[6].Value = where; parameters[7].Direction = ParameterDirection.Output; try { dr = SqlHelper.ExecuteReader(DbHelperSQL.connectionString, CommandType.StoredProcedure, "sp_PageGetComm_Row", parameters); while (dr.Read()) { linkList.Add(SqlDataReaderTOObject(dr)); } dr.Close();//关闭读取后才能获取返回信息 [color=#008000] pageCount = Convert.ToInt32(parameters[7].Value.ToString());[/color] } finally { if (dr != null && !dr.IsClosed) dr.Close(); } return linkList; }