locked
SqlHelper parameter count - can I overcome this ? RRS feed

  • Question

  • User-892324794 posted

     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 !

    Wednesday, July 15, 2009 3:59 AM

All replies

  • User1100692814 posted

    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

    Wednesday, July 15, 2009 5:06 AM
  • User-2126908451 posted

     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

    Wednesday, July 15, 2009 5:09 AM
  • User-319574463 posted

    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.

    Wednesday, July 15, 2009 6:12 AM
  • User-892324794 posted

    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 ..

    Wednesday, July 15, 2009 8:03 AM