The following articles mainly introduce the parameters related to Oracle stored procedures. The first three functions are input parameters, and the last three functions are output parameters, if you are not familiar with the actual application of parameters related to Oracle stored procedures, the following articles will provide you with relevant knowledge.
- Help.cs:
- public static DataTable ReturnDataTable(int index,string sql,int pageSize)
- {
- DataTable dt = new DataTable();
- try
- {
- OracleParameter []param=new OracleParameter
[]{new OracleParameter("Pindex",OracleType.Number),
new OracleParameter("Psql",OracleType.VarChar),
new OracleParameter("Psize",OracleType.Number),
new OracleParameter("Pcount",OracleType.Number),
new OracleParameter("Prowcount",OracleType.Number),
new OracleParameter("v_cur",OracleType.Cursor)};
- param[0].Value = index;
- param[1].Value = sql;
- param[2].Value = pageSize;
- param[0].Direction = ParameterDirection.Input;
- param[1].Direction = ParameterDirection.Input;
- param[2].Direction = ParameterDirection.Input;
- param[3].Direction = ParameterDirection.Output;
- param[4].Direction = ParameterDirection.Output;
- param[5].Direction = ParameterDirection.Output;
- dt= OracleHelper.ReturnDataTable(OracleHelper.dbCon,
CommandType.StoredProcedure, "JT_P_page.Pagination", param);
- Help._rowCount = int.Parse(param[4].Value.ToString());
- }
- catch (OracleException on)
- {
- throw on;
- }
- return dt;
- }
Note that the parameter name must be consistent with the parameter in the Oracle stored procedure. Otherwise, an error may be returned, for example, new OracleParameter ("Pindex", OracleType. in Number), like Pindex in the Stored procedure Pagination (Pindex in number, Aspnetpage, as a third-party control, is directly downloaded from the internet and then stored in the VS2005 toolbar. after importing the dll, you can use the Update_Agent.aspx.cs file on the front-end page:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- BindGridView(0, "union_view", _pageSize);
- AspNetPager1.RecordCount = (Help._rowCount >= 0) ? Help._rowCount : 0;
- }
- }
- private void BindGridView(int index, string sql, int pageSize)
- {
- DataTable dt;
- if (sql != "")
- {
- ViewState["IsProcedure"] = "yes";
- dt = Help.ReturnDataTable(index, sql, pageSize);
- }
- else
- {
- ViewState["IsProcedure"] = "no";
- dt = Help.ReturnDataTableByCondition
(dateinput.Value, dateinput2.Value,
orderID.Value.Trim(), dgWay.SelectedValue,
AspNetPager1.CurrentPageIndex - 1, AspNetPager1.PageSize);
- }
- iagentView.DataSource = dt;
- DataBind();
- AspNetPager1.RecordCount = (sql!="")?Help._rowCount:
Help.ReturnRows(dateinput.Value, dateinput2.Value,
orderID.Value.Trim(), dgWay.SelectedValue);
- AspNetPager1.PageSize = pageSize;
The above content is an introduction to the relevant parameters of the Oracle stored procedure. I hope you will find some gains.