4
Answers

How to make function by c# to call stored proc from sql

ahmed salah

ahmed salah

7y
217
1
I work in visual studio 2015 c# and i need to call stored procedure from sql 2012
and make function by c# to call stored procedure and retrieve one value string
in case name = @name 
 
  1. ALTER PROCEDURE [dbo].[ATC_Code_ByGeneric_H]  
  2.     @Lvl_Name nvarchar(500)  
  3. AS  
  4.     SELECT     Tbl_Lvl1.Code + Tbl_Lvl2.Code + Tbl_Lvl3.Code + Tbl_Lvl4.Code + Tbl_Lvl5.Code AS ATC_Code  
  5.     FROM         Tbl_Lvl1  
  6.                  INNER JOIN  
  7.                  Tbl_Lvl2  
  8.                  ON Tbl_Lvl1.S_ID = Tbl_Lvl2.UpLvl_ID  
  9.                  INNER JOIN  
  10.                  Tbl_Lvl3  
  11.                  ON Tbl_Lvl2.S_ID = Tbl_Lvl3.UpLvl_ID  
  12.                  INNER JOIN  
  13.                  Tbl_Lvl4  
  14.                  ON Tbl_Lvl3.S_ID = Tbl_Lvl4.UpLvl_ID  
  15.                  INNER JOIN  
  16.                  Tbl_Lvl5  
  17.                  ON Tbl_Lvl4.S_ID = Tbl_Lvl5.UpLvl_ID  
  18.     WHERE     (Tbl_Lvl5.Lvl_Name = @Lvl_Name) and Tbl_Lvl5.human=1  
  19.     RETURN  
 Actually i need to retrieve ATC_Code in case of Lv1_Name = @Lv1_Name
How to create function return string by c# to call stored procedure ? 

Answers (4)