如何从存储过程返回所有记录? [英] How could I return all records from a stored procedure?

查看:27
本文介绍了如何从存储过程返回所有记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个存储过程

i am using this stored procedure

ALTER PROCEDURE [dbo].[MyProcedure]
    @pSelect nvarchar(max)

AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @SQL nvarchar(max)

    SET @SQL = 'select ' + @pSelect + ' from vwAcdAdmissionWithvwAcdAdmissionSessionDetailWithAllMaster';
     EXEC (@SQL)

END

并使用 linq 从 c#.net entitydatamodel 执行它

and executing it from c#.net entitydatamodel with linq

shoolSoulDataEntites db = new schoolSoulDataEntites;var ss = db.Myprocedure("column1,column2");

shoolSoulDataEntites db = new schoolSoulDataEntites; var ss = db.Myprocedure("column1,column2");

但它返回一个整数值我想要程序结果的所有记录请帮助我

but it is returning a integer value i want all records of the result of procedure plss help me

推荐答案

但它返回一个整数值

but it is returning a integer value

不,它不返回整数值.

正是您调用的方法返回了整数值.我猜你正在调用 ExecuteScalar 来执行存储过程.您需要将其更改为 executeNonQuery 并使用一些数据适配器来填充您的数据集/数据表.

It is the method that you are calling that is returning you integer value. I guess you are calling ExecuteScalar to execute store procedure. You need to change it to executeNonQuery and use some dataadapter to fill up your dataset/datatable.

这篇关于如何从存储过程返回所有记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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