Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Http [Attribute], return value from Stored Procedure

$
0
0

Hi All,

I need guidance for getting a return value from Stored Procedure.

This is the current Controller

        [HttpPost]
        public IActionResult Index (prj_Insert Project) {
            var Project = new SqlParameter("@Project", Project.Project);
            var State = new SqlParameter("@State", Project.State);
            var _Insert = _project.Database.ExecuteSqlCommand("[dbo].[Insert_Top1] @Project, @State"

                                                               , Project
                                                               , State);
            return View ();
        }

This is for Store Procedure and @ID_Project is for a return value. 

ALTER PROCEDURE [dbo].[Project_Code_Insert]
	-- Add the parameters for the stored procedure here

        @Project	NVARCHAR(5)
	, @State	NVARCHAR(3)
	, @ID_Project	INT             OUTPUTAS
BEGIN
	INSERT INTO [dbo].[Tbl_Top1] ([Project], [State]) VALUES (@Project, @State)

	SELECT @ID_Project = @@IDENTITY

I know that controller above need modification to retrieve value from stored procedure but how to prepare a return value in theController ?

Please, advice me

Thanks in Adv, #D

 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>