存储过程
/// <summary>
/// 分页获取数据列表
/// </summary>
public virtual DataSet GetList(string tableName, string columnName, int PageSize, int PageIndex, bool isCount, string strWhere)
{
SqlParameter[] parameters = {
new SqlParameter("@tblName", SqlDbType.VarChar, 255),
new SqlParameter("@fldName", SqlDbType.VarChar, 255),
new SqlParameter("@PageSize", SqlDbType.Int),
new SqlParameter("@PageIndex", SqlDbType.Int),
new SqlParameter("@IsCount", SqlDbType.Bit),
new SqlParameter("@OrderType", SqlDbType.Bit),
new SqlParameter("@strWhere", SqlDbType.VarChar,1000)
};
parameters[0].Value = tableName;
parameters[1].Value = columnName;
parameters[2].Value = PageSize;
parameters[3].Value = PageIndex;
parameters[4].Value = isCount;
parameters[5].Value = 0;
parameters[6].Value = strWhere;
DataSet ds = DbHelperSQL.RunProcedure("GetRecordFromPage", parameters, "ds"); //存储过程调用
return ds;
}\
/// <summary>
/// 执行存储过程
/// </summary>
/// <param name="storedProcName">存储过程名</param>
/// <param name="parameters">存储过程参数</param>
/// <param name="tableName">DataSet结果中的表名</param>
/// <returns>DataSet</returns>
public static DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName)
{
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, tableName);
connection.Close();
return dataSet;
}
}