以下的文章主要是涉及Oracle存儲過程的相關參數的介紹,其中 前三個函數是輸入參數,後3個函數是輸出參數,對Oracle存儲過程的相關參數的相關實際應用不是很了解的話,以下的文章會給你提供相關的知識。
- 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;
- }
注意一下再調用的時候 參數名必須和Oracle存儲過程中的參數保持一致 否則可能會報錯 例如:new OracleParameter("Pindex",OracleType.Number) 中的 Pindex 和存儲過程procedure Pagination (Pindex in number 中的一樣,Aspnetpage作為一個第三方控件,直接從網上下載後 在VS2005工具欄裡把.dll導進去 就可以拿來用了 前台頁面Update_Agent.ASPx.cs裡:
- 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;