数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

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


发布日期:2022年12月12日
 
ADO.NET访问Oracle 9i存储过程(上)[8]

以下代码执行该过程根据结果集创建 DataReader并将 DataReader 的内容输出到控制台

// create connection

OracleConnection conn = new OracleConnection(Data Source=oracledb;

User Id=UserID;Password=Password;);

// create the command for the stored procedure

OracleCommand cmd = new OracleCommand();

cmdConnection = conn;

cmdCommandText = SELECT_JOB_HISTORYGetJobHistoryByEmployeeId;

cmdCommandType = CommandTypeStoredProcedure;

// add the parameters for the stored procedure including the REF CURSOR

// to retrieve the result set

cmdParametersAdd(p_employee_id OracleTypeNumber)Value = ;

cmdParametersAdd(cur_JobHistory OracleTypeCursor)Direction =

ParameterDirectionOutput;

// open the connection and create the DataReader

connOpen();

OracleDataReader dr = cmdExecuteReader();

// output the results and close the connection

while(drRead())

{

for(int i = ; i <drFieldCount; i++)

ConsoleWrite(dr[i]ToString() + ;);

ConsoleWriteLine();

}

connClose();

[] [] [] [] [] [] [] []

               

上一篇:ADO.NET访问Oracle 9i存储过程(上)[4]

下一篇:ADO.NET访问Oracle 9i存储过程(上)[5]