System.Void 'is not a valid return type for the associated stored procedure method

I am trying to execute pro in SQL Server from LINQ in asp.net. It works fine when I execute Proc in SQL, but when I try to call it from linq in asp.net, it gives the following error: "System.Void" is not a valid return type for the associated stored procedure method "Here is my good,

ALTER PROCEDURE [dbo].[VIEW_COLUMN] @REPORT_NO INT , @TEMPLATE_NAME VARCHAR(100), @BODY_TEXT VARCHAR(500), @BODY_TEXT_O VARCHAR(500) OUTPUT AS BEGIN --DECLARE VARIABLES-- DECLARE @BODY_TEXT VARCHAR(100) ----------- etc---- ------etc etc----- SET @BODY_TEXT_O = @BODY_TEXT END 

On my ASP.net page

  using (EHSIMSDataContext db = new EHSIMSDataContext(EHSIMSConnectionString.GetConnectionString())) { string MainString = _EmailTemp.TEMPLATE_TEXT; int? R = 000001; string b = ""; string temname = _EmailTemp.VIEW_NAME; db.VIEW_COLUMN(R, temname, MainString, ref b); } 

After the error, I googled and changed my designer page to, (deleted void and added a line and added the last return line)

  public string VIEW_COLUMN ------etc { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), rEPORT_NO, tEMPLATE_NAME, bODY_TEXT, bODY_TEXT_O); bODY_TEXT_O = ((string)(result.GetParameterValue(3))); return ((string)(result.ReturnValue)); } 

And there is no return in the above code, as well as as the โ€œPublic Void VIEW_COLUMNโ€ method, it still showed some other error, and I also tried to set the string as the return type in the DBML file of the properties of my procedures is still useless, I donโ€™t know what lacks.

Additional Information Do I have a Temp variable and a table in my procedure, maybe the reason?

Some answers will be really helpful ... Thanks

+4
source share
2 answers

Try modifying the stored procedure so that it returns text directly, and not through the output parameter.

Add another line to the end:

 SELECT @BODY_TEXT_O; 
0
source

You are close; you need to change the return type for your stored procedure (inside your dbml) to int.

Linq actually executes this sql command, which returns the result as int:

 DECLARE @ReturnValue int EXEC @ReturnValue = [dbo].[VIEW_COLUMN] SELECT 'ReturnValue' = @ReturnValue 
0
source

Source: https://habr.com/ru/post/1491834/


All Articles