This topic is locked

Stored Procedure

10/18/2018 10:23:49 AM
ASPRunner.NET General questions
K
kleanthis author

I have a store procedure name "TestOver3" and i want to check if it return any values. I used the following code in the Before record added.

string strSQLExists2 = "EXEC TestOver3 '" + values["Class"].ToString() + "', '" + values["Divide"].ToString() + "', '"+DateWeek+"'";

XVar rsExists2 = CommonFunctions.db_query(strSQLExists2, null);

XVar data2 = CommonFunctions.db_fetch(rsExists2);

if(data2)

{

message = "ΥΠΑΡΧΟΥΝ 3 ΔΙΑΓΩΝΙΣΜΑΤΑ ΑΥΤΗ ΤΗΝ ΕΒΔΟΜΑΔΑ";

return false;

}

else


Thx for your help.

T
Tim 10/18/2018

I have executed a stored procedure and then used the returned data before. Here is the post where I explain:
http://asprunner.com/forums/topic/22809-assign-value-returned-by-stored-procedure-to-varible/
Hope this helps.
Thanks,

Tim

K
kleanthis author 10/18/2018

Hi Tim

thanks for your respond.

I try this but is not working. Can you help me pls.

string sql = "DECLARE @return_value int EXEC TestOver3 '" + values["Class"].ToString() + "', '" + values["Divide"].ToString() + "', '"+DateWeek+"' SELECT 'Return Value' = @return_value";

XVar rs = tDAL.CustomQuery(sql);

XVar data2 = CommonFunctions.db_fetch_array(rs);
if(data2)

{

message = data2;

}

{

return true;

}


thx again.

K
kleanthis author 10/18/2018

Hi Tim

thanks for your respond.

I try this but is not working. Can you help me pls.

string sql = "DECLARE @return_value int EXEC TestOver3 '" + values["Class"].ToString() + "', '" + values["Divide"].ToString() + "', '"+DateWeek+"' SELECT 'Return Value' = @return_value";

XVar rs = tDAL.CustomQuery(sql);

XVar data2 = CommonFunctions.db_fetch_array(rs);
if(data2)

{

message = data2;

}

{

return true;

}


thx again.

T
Tim 10/18/2018

Try this:

if(data2)

{

message = data2["Return Value"].ToString();

}


And note that your declared variable is an int, so it is expecting that you are returning an number. If you are returning text change that to a varchar.
I should also note that I am no expert, but this is my best guess.
Good luck.
Tim