ASP.NET呼叫oracle儲存過程實現快速分頁
阿新 • • 發佈:2019-01-22
{
OracleConnection conn =new OracleConnection(ConfigurationSettings.AppSettings["OracleConnstr"].ToString());
OracleCommand cmd =new OracleCommand();
cmd.Connection = conn;
cmd.CommandText ="MaterialManage.Per_QuickPage";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("TbName ",OracleType.VarChar,50); //表 名
cmd.Parameters["TbName"].Direction = ParameterDirection.Input;
cmd.Parameters["TbName"].Value = TbName;
cmd.Parameters.Add("FieldStr",OracleType.VarChar,3000); //欄位集
cmd.Parameters["FieldStr"].Direction = ParameterDirection.Input;
cmd.Parameters["FieldStr"].Value = FieldStr;
cmd.Parameters.Add("RowFilter",OracleType.VarChar,3000); //過濾條件
cmd.Parameters["RowFilter"].Direction = ParameterDirection.Input;
cmd.Parameters["RowFilter"].Value = RowFilter;
cmd.Parameters.Add("SortStr",OracleType.VarChar,3000); //排序欄位
cmd.Parameters["SortStr"].Direction = ParameterDirection.Input;
cmd.Parameters["SortStr"].Value = SortStr;
cmd.Parameters.Add("MinRowNum",OracleType.Number); //分頁小值
cmd.Parameters["MinRowNum"].Direction = ParameterDirection.Input;
cmd.Parameters["MinRowNum"].Value = MinRowNum;
cmd.Parameters.Add("MaxRowNum",OracleType.Number); //分頁大值
cmd.Parameters["MaxRowNum"].Direction = ParameterDirection.Input;
cmd.Parameters["MaxRowNum"].Value = MaxRowNum;
cmd.Parameters.Add("TotalCount",OracleType.Number); //頁總記錄數
cmd.Parameters["TotalCount"].Direction = ParameterDirection.Output;
cmd.Parameters["TotalCount"].Value =0;
cmd.Parameters.Add("Cur_ReturnCur",OracleType.Cursor); //返回的遊標
cmd.Parameters["Cur_ReturnCur"].Direction = ParameterDirection.Output;
DataSet Ds =new DataSet();
OracleDataAdapter adapter=new OracleDataAdapter(cmd);
adapter.Fill(Ds);
conn.Close();
//總記錄數
RecordCount =int.Parse(cmd.Parameters["TotalCount"].Value.ToString());
return Ds.Tables[0];
}
OracleConnection conn =new OracleConnection(ConfigurationSettings.AppSettings["OracleConnstr"].ToString());
OracleCommand cmd =new OracleCommand();
cmd.Connection = conn;
cmd.CommandText ="MaterialManage.Per_QuickPage";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("TbName
cmd.Parameters["TbName"].Direction = ParameterDirection.Input;
cmd.Parameters["TbName"].Value = TbName;
cmd.Parameters.Add("FieldStr",OracleType.VarChar,3000); //欄位集
cmd.Parameters["FieldStr"].Direction = ParameterDirection.Input;
cmd.Parameters["FieldStr"].Value
cmd.Parameters.Add("RowFilter",OracleType.VarChar,3000); //過濾條件
cmd.Parameters["RowFilter"].Direction = ParameterDirection.Input;
cmd.Parameters["RowFilter"].Value = RowFilter;
cmd.Parameters.Add("SortStr",OracleType.VarChar,3000); //排序欄位
cmd.Parameters["SortStr"].Direction = ParameterDirection.Input;
cmd.Parameters.Add("MinRowNum",OracleType.Number); //分頁小值
cmd.Parameters["MinRowNum"].Direction = ParameterDirection.Input;
cmd.Parameters["MinRowNum"].Value = MinRowNum;
cmd.Parameters.Add("MaxRowNum",OracleType.Number); //分頁大值
cmd.Parameters["MaxRowNum"].Direction = ParameterDirection.Input;
cmd.Parameters["MaxRowNum"].Value = MaxRowNum;
cmd.Parameters.Add("TotalCount",OracleType.Number); //頁總記錄數
cmd.Parameters["TotalCount"].Direction = ParameterDirection.Output;
cmd.Parameters["TotalCount"].Value =0;
cmd.Parameters.Add("Cur_ReturnCur",OracleType.Cursor); //返回的遊標
cmd.Parameters["Cur_ReturnCur"].Direction = ParameterDirection.Output;
DataSet Ds =new DataSet();
OracleDataAdapter adapter=new OracleDataAdapter(cmd);
adapter.Fill(Ds);
conn.Close();
//總記錄數
RecordCount =int.Parse(cmd.Parameters["TotalCount"].Value.ToString());
return Ds.Tables[0];
}