none
How to make function by c# to call stored proc from sql and return string

    Question

  •  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 
     
    ALTER PROCEDURE [dbo].[ATC_Code_ByGeneric_H]  
        @Lvl_Name nvarchar(500)  
    AS  
        SELECT     Tbl_Lvl1.Code + Tbl_Lvl2.Code + Tbl_Lvl3.Code + Tbl_Lvl4.Code + Tbl_Lvl5.Code AS ATC_Code  
        FROM         Tbl_Lvl1  
                     INNER JOIN  
                     Tbl_Lvl2  
                     ON Tbl_Lvl1.S_ID = Tbl_Lvl2.UpLvl_ID  
                     INNER JOIN  
                     Tbl_Lvl3  
                     ON Tbl_Lvl2.S_ID = Tbl_Lvl3.UpLvl_ID  
                     INNER JOIN  
                     Tbl_Lvl4  
                     ON Tbl_Lvl3.S_ID = Tbl_Lvl4.UpLvl_ID  
                     INNER JOIN  
                     Tbl_Lvl5  
                     ON Tbl_Lvl4.S_ID = Tbl_Lvl5.UpLvl_ID  
        WHERE     (Tbl_Lvl5.Lvl_Name = @Lvl_Name) and Tbl_Lvl5.human=1  
        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 ? 
    Thursday, April 27, 2017 11:34 AM

All replies