如何在c#中使用有效的表名检索存储过程输出值 [英] How to retrieve the stored procedure output values with valid table names in c#

查看:92
本文介绍了如何在c#中使用有效的表名检索存储过程输出值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

we developed one stored procedure like this

CREATE OR REPLACE PROCEDURE CPCE.SP_GET_SUBJECTIVE_EFILE_DATA
(
IN @RptGrpId    INTEGER,
IN @BatchId     INTEGER,
IN @UserId      VARCHAR,
IN @LogMessage  VARCHAR,
OUT @ListCaseReportsCurType CURSOR,
OUT @ListCrDisclosureCurType CURSOR,
OUT @ListCrDisclosureTranDetailAllCurType CURSOR,
OUT @ListCrSarSubPhotoIdAllCurType CURSOR,
OUT @ListRptGrpStaticDataCurType CURSOR,
OUT @ListCountryRptGrpCurType CURSOR,
OUT @ListIdTypeAllCurType CURSOR,
OUT @ListRptGrpCountryAliasCurType CURSOR,
OUT @ListRptGrpStateAliasCurType CURSOR,
OUT @ListRptGrpCityAliasCurType CURSOR,
OUT @ListAgentProfileCurType CURSOR
)
In this stored procedure we are returning the out parameters. In C# code we are calling the stored procedure and retrieving the values like this

DB2Command cmd = new DB2Command("CPCE.SP_GET_SUBJECTIVE_REPORT_DETAILS_FOR_EFILE", connection);
                wParam.dsResult = new DataSet();
                cmd.CommandTimeout = 0;
                cmd.Connection = connection;
                cmd.CommandType = CommandType.StoredProcedure;
                AddParamsForSp(wParam, cmd);
                DB2DataAdapter da = new DB2DataAdapter(cmd);
                da.Fill(wParam.dsResult);
Here we are reading all the values to the dsResult dataset, it contains all the datatables we are retrieving the table values like this

   dtCaseReports = wParam.dsResult.Tables["Table0"];
                dtCrDisclosure = wParam.dsResult.Tables["Table1"];
                dtCrDiscTransDetails = wParam.dsResult.Tables["Table2"];
                dtSubjectPhotoId = wParam.dsResult.Tables["Table3"];
                dtStaticData = wParam.dsResult.Tables["Table4"];
I can able to retrieve all the values but i want to retrieve the values with the valid table names because it is very difficult to remember the Table0,Table1...like this

What we need to change in the stored procedure side for this requirement.

推荐答案

嗨trinadh,



在C#中没有构建方式来执行此操作。你必须编写自己的函数或逻辑来执行此操作。本文介绍了如何执行此操作。



http://stackoverflow.com/questions/5699983/datasets-with-actual-tablename [ ^ ]
Hi trinadh,

There is no in build way in C# for doing this. You have to write your own function or logic for doing this. This article explains how you can do this.

http://stackoverflow.com/questions/5699983/datasets-with-actual-tablename[^]


这篇关于如何在c#中使用有效的表名检索存储过程输出值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆