您现在的位置是:首页 >

怎么调用存储过程 ADO.NET访问Oracle 9i存储过程(上)[8]

火烧 2022-06-28 23:43:51 1065
ADO.NET访问Oracle 9i存储过程 上 [8]   以下代码执行该过程 根据结果集创建 DataReader 并将 DataReader 的内容输出到控制台  // create co ec

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]

  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  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码