SqlHelper parameter count - can I overcome this ?

Last post 07-15-2009 8:03 AM by Johnny_Boy. 4 replies.

Sort Posts:

  • SqlHelper parameter count - can I overcome this ?

    07-15-2009, 3:59 AM
    • Member
      9 point Member
    • Johnny_Boy
    • Member since 10-22-2007, 4:06 PM
    • Posts 61

     Hi there,

    I have a stored procedure that works with a live site perfectly.

    However, I wish to change the procedure to include more parameters, but from previous tryouts it resulted the site throwing SqlException of message "Parameter count does not match parameter value count". The change was adding a parameter with default value, but it seems that the SqlHelper checks the actual parameter count prior to setting the variables.

    What I had to do in these case is to create another stored procedure with a suffix of "_temp", testin it with it, publishing the site again and then copying the "_temp" procedure to the live one for the changes to take affect.

    Is there a better solution for this ? What would you do if you were me ?

    Thanks !

  • Re: SqlHelper parameter count - can I overcome this ?

    07-15-2009, 5:06 AM
    • Participant
      1,082 point Participant
    • Dave_Winchester
    • Member since 03-03-2006, 3:13 PM
    • United Kingdom
    • Posts 338

    Hi

    Are you using datasets / tableadapters? I have had a similar problem and had to redo the whole thing when I have added more fields. Also, how are you displaying the data i.e. IDataReader etc...

    Thanks

    Dave

    David Winchester

    Please mark as answer if this is the solution.
  • Re: SqlHelper parameter count - can I overcome this ?

    07-15-2009, 5:09 AM
    • Participant
      966 point Participant
    • nileshdeokar
    • Member since 12-29-2007, 7:01 AM
    • Posts 164

     delete temp files from "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"

    also add new parameters at the end only with default values other wise it throws error or it will not assigned values properly.If possible post 4-5 lines of your SP so I can help you

     

    Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution

  • Re: SqlHelper parameter count - can I overcome this ?

    07-15-2009, 6:12 AM
    • All-Star
      62,543 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 8:34 AM
    • England
    • Posts 12,210
    • TrustedFriends-MVPs

    This is a where a separate data layer becomes very useful. If usp_PersonSelect is called by the SelectRecord method in Person.cs, make a new stored procedure usp_PersonSelect2 called by SelectRecord2. You can now unit test the new routine and then progressively migrate from SelectRecord to SelectRecord2.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: SqlHelper parameter count - can I overcome this ?

    07-15-2009, 8:03 AM
    • Member
      9 point Member
    • Johnny_Boy
    • Member since 10-22-2007, 4:06 PM
    • Posts 61

    That's what I wish to avoid. Migrating from say SelectRecord to SelectRecord2.

    I want to still be using SelectRecord.

    If that's not possible, then I have two options:

    1) Create another exact SP to work on, and after testing upload the new code that handles the extra parameters and immediately after alter the main SP to be exactly as the backup one. Then just delete the backup.

    2) Try to edit the SqlHelper's code and remark the code that checks for parameter count.

    I suppose no one has a #3, #4 ... solutions ..

Page 1 of 1 (5 items)