행 수가 제한되도록 다음 코드를 수정해야합니다.행 제한이있는 데이터 어댑터로 데이터 세트 채우기
// create the connection
OracleConnection conn = new OracleConnection("Data Source=oracledb;
User Id=UserID;Password=Password;");
// create the command for the stored procedure
OracleCommand cmd = new OracleCommand();
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 = 101;
cmd.Parameters.Add("cur_JobHistory", OracleType.Cursor).Direction =
ParameterDirection.Output;
// createt the DataAdapter from the command and use it to fill the
// DataSet
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);//Here is where I need to limit the rows
최대 개수를 채우는 방법이 있습니다.
public int Fill( DataSet dataSet, int startRecord, int maxRecords, string srcTable )
그러나, 나는 srcTable에 전달해야하는지 모른다. 내 저장된 proc에는 하나의 REF_CURSOR (OUT TYPES.REF_CURSOR)이 있습니다.
도움을 주시면 감사하겠습니다.
코드 조각에서 알 수 있듯이 데이터 세트에 추가 된 테이블이 없습니다. 출력은 커서입니다. – Jimmy
'DataSet'을 임의의 데이터로 채우면 자동적으로'DataTable'이 생성되고 추가됩니다. 'Fill'을 지나서 디버거에있는'Tables' 속성을 봅니다. 테이블을 명시 적으로 delcare하지 않았기 때문에'ds.Tables [0] .TableName' 예제를 사용할 수 있습니다. –
왜 코드를 던져서는 안됩니까? 방금 데이터 세트를 만들었고 그 당시에는 테이블이 없었습니다. 여전히 인덱스 0을 함수에 전달하려고합니다. – Jimmy