Stored Procedure return values with SqlParameterHelper

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/23/2010 4:52:09 PM
Gravatar
Total Posts 190

Stored Procedure return values with SqlParameterHelper

Would it be correct to conclude that SqlParameterHelper does not support ParameterDirection.ReturnValue? I can't seem to make it work. If I include a parameter for it, it seems the SqlParameterHelper wants to match the declared number of parameters only for the input parameters. If you only count input params for the number, then it says you have too many parameters. So you get errors either way.

Thanks,

John

3/24/2010 8:35:46 AM
Gravatar
Total Posts 18439

Re: Stored Procedure return values with SqlParameterHelper

Hi John,

Yes, it is probably true since it was developed to support things I'm using and I'm not using return values per se.

Typically anything you would return like

return @@error

or 

return @@IDENTITY

can also be expressed as

SELECT @@error

or

SELECT @@IDENTITY

and then you can just use ExecuteScalar

Alternatively you don't have to use sqlparameterhelper, you can use amore direct approach:

SqlParameter[] arParams = new SqlParameter[1];

            arParams[0] = new SqlParameter("@ProductGuid", SqlDbType.UniqueIdentifier);
            arParams[0].Direction = ParameterDirection.Input;
            arParams[0].Value = productGuid;

            int rowsAffected = SqlHelper.ExecuteNonQuery(GetConnectionString(),
                CommandType.StoredProcedure,
                "ws_ProductFile_Delete",
                arParams);

            return (rowsAffected > -1);

Hope it helps,

Joe

3/24/2010 9:59:29 AM
Gravatar
Total Posts 190

Re: Stored Procedure return values with SqlParameterHelper

Thanks Joe. I did get the solution worked out with an output parameter. Actually, I did use the SELECT method in a couple of instances. But in some cases where I was trying to use the return value I was able to replace that with an output parameter. I also noted that when you add the parameter, the direction has to be set to InputOutput and not Output or it will still throw an error. But it's all good now. (the Transit site should be live in a few weeks. Middle of next month or so. It has many very cool features.)

You must sign in to post in the forums. This thread is closed to new posts.