Click here to Skip to main content
15,885,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using MVC 4 with Linq to SQL class and using stored procedure for my transaction.
I have simple stored procedure having two output parameters with different data types. I am struggling to retrieve the values of both return by stored procedure.

My SP like as :
SQL
Create Procedure [dbo].[tblMgmt_test_sp] 
@numAmt_Actual int=0 output, 
@return varchar(20)=null output  
AS  
.....
....


And my Controller action is as -
C#
int? numAmt_Actual = 1;
string returnVal = "";

var strResult = datacontext.tblMgmt_test_sp(ref numAmt_Actual ,ref returnVal);


Not sure which datatype to hold the result of datacontext.tblMgmt_test_sp and how?

Can you please help me regarding this issue?
Posted
Updated 14-Oct-15 1:22am
v2
Comments
[no name] 14-Oct-15 7:27am    
If it is a varchar type in SQL server then string is fine. Your code looks OK. Are you getting any kind of exception?
Ajay_Saini 14-Oct-15 7:59am    
No, i didn't get any exception and any value of output variable i.e. @numAmt_Actual and @return in my case (if i use different data types).
And yes if both the output valuables are of same type then i got both values but for different type then i got following exception -

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

Even the return type i have seen in designer class is not as 'Void'
Sinisa Hajnal 14-Oct-15 11:16am    
Void means it didn't return anything. What are you expecting from the stored procedure? DataSet? Did you check that SP really returns some data?
Ajay_Saini 14-Oct-15 12:14pm    
I just want to get the values of out variables define in stored procedure but keeping in mind that both the output variables have different data types.
Ajay_Saini 15-Oct-15 1:23am    
Hi Sinisa,
I have checked again and found the values at this time, not sure what is the problem as same code i have tested in my morning and seems working for me now.

 
Share this answer
 
Comments
Ajay_Saini 14-Oct-15 12:20pm    
This is not a solution as per my problem.
I can retrieve multiple out variables in case of ado or ado.net but how to get all the out variable's value in MVC using Linq to SQL is my concern. Please read my question for more info.
The above query is fixed at my end without modifying any part in my code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900