样本存储过程调用代码,该代码从存储过程返回xmloutput

问题描述:

大家好,
我写了一个带有两个参数的存储过程.一个是custnumber(输入参数),另一个是xmloutput参数(输出参数).在传递custid的同时创建其xmloutput结果.要生成xmloutput,我已经写了:
FOR XML PATH(''客户''),ROOT(''doc'').
从后端运行此存储过程时,我得到了xml格式的正确结果.

现在,我想从C#.net DAL层调用此存储过程,返回的存储过程结果应在Dataset中(我的意思是,将有一种方法的返回类型为数据集).虽然我会从表示层调用此数据集返回类型的方法以在Gridview中显示:我该怎么办????请帮助示例编码.

Hi all,
i have written one Stored Procdure which has two paramters. One is custnumber(input parameter) another one is xmloutput parameter(outputparameter).While passing custid its creating xmloutput result.To generate xmloutput i have written:
FOR XML PATH(''Customer''), ROOT(''doc'').
While running this Stored Procdure from backend i am getting the correct result in xml format.

Now i want to call this Stored Procedure from C#.net DAL layer return the Stored Procedure result should be in Dataset(i mean there will be a method whose return type will be dataset). And while i will call this dataset return type method from presentation layer want to display in gridview: how can i do this????pls help with sample coding.

这应该对您有帮助:
ADO.NET概述 [在ADO.NET中使用数据集 [
This should help you out:
ADO.NET Overview[^]
Using Dataset in ADO.NET[^]

Using ADO.NET, get data in a dataset. Once you have dataset, pass that back to UI layer where you can bind it to the datagrid.

While fetching data, instead of query you would be using stored procedure. For that, commandType would be SP.

Try!


查看以下文章,将其按您所说的获取到数据集.

将XML转换为强类型数据集 [
check out the below article to get that to dataset as you said.

Convert XML to Strongly Typed DataSets[^]

In your SP,have a refcursor something like below & get the xml column selected into the ref cursor.


PROCEDURE PRC_GET_TEMPLATES(

o_output OUT PKG_XXX.g_refcur
)
IS


BEGIN
OPEN o_output FOR
SELECT * FROM table