怎么调用存储过程 ADO.NET访问Oracle 9i存储过程(上)[8]
ADO.NET访问Oracle 9i存储过程(上)[8]
以下代码执行该过程 根据结果集创建 DataReader 并将 DataReader 的内容输出到控制台
// create connection
OracleConnection conn = new OracleConnection( Data Source=oracledb;
User Id=UserID;Password=Password; );
// create the mand for the stored procedure
OracleCommand cmd = new OracleCommand();
![怎么调用存储过程 ADO.NET访问Oracle 9i存储过程(上)[8]](http://img.zhputi.com/uploads/6453/6453ae76a9cf338ab77427da91507fe126682.jpg)
cmd Connection = conn;
cmd CommandText = SELECT_JOB_HISTORY GetJobHistoryByEmployeeId ;
cmd CommandType = CommandType StoredProcedure;
// add the parameters for the stored procedure including the REF CURSOR
// to retrieve the result set
cmd Parameters Add( p_employee_id OracleType Number) Value = ;
cmd Parameters Add( cur_JobHistory OracleType Cursor) Direction =
ParameterDirection Output;
// open the connection and create the DataReader
conn Open();
OracleDataReader dr = cmd ExecuteReader();
// output the results and close the connection
while(dr Read())
{
for(int i = ; i <dr FieldCount; i++)
Console Write(dr[i] ToString() + ; );
Console WriteLine();
}
conn Close();
lishixinzhi/Article/program/net/201311/15010