Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • jernej 7 posts 28 karma points
    Nov 19, 2009 @ 21:35
    jernej
    0

    stored procedures & Umbraco

    Hi, I'm trying to fill a datareader with records returned from a stored procedure. I'm using the code pasted below, and it works only on stored procedures with no parameters. If the sp expects a parameter, despite beeing provided, this code returns an error saying that I did not provide a parameter :

     

    string sp_name = "sp_SelectAllProducts";

    IParameter p3 = umbraco.BusinessLogic.Application.SqlHelper.CreateParameter("@intParent", 5);

    IRecordsReader reader = umbraco.BusinessLogic.Application.SqlHelper.ExecuteReader(sp_name,p3);

     

    Any sugestions what could be the problem?

    Thanks for your help!

     

     

     

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Nov 22, 2009 @ 13:13
    Morten Bock
    0

    Problem is that internally, the method looks like this:

            protected override IRecordsReader ExecuteReader(string commandText, SqlParameter[] parameters)
            {
                return new SqlServerDataReader(SH.ExecuteReader(ConnectionString, CommandType.Text, commandText, parameters));
            }
    So it is fired a CommandType.Text and not CommandType.StoredProcedure.
    You probably need to add the parameter to your sp_name variable yourself.

  • jernej 7 posts 28 karma points
    Nov 22, 2009 @ 22:18
    jernej
    1

    yeah thanks, this solved the problem:

     string sql = "sp_SelectAllProductst @intparent";

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies