1

I have a problem with a SQL Server stored procedure. Although I supply parameter, and although the parameter is not null, I got 'parameter is not supplied' error

My C# code is here:

staffInfo.DeleteCommand = "deleteStaff";
staffInfo.DeleteCommandType = SqlDataSourceCommandType.StoredProcedure;
staffInfo.DeleteParameters.Add("tcId", stafftc);
staffInfo.Delete();

Stored procedure:

ALTER PROCEDURE dbo.deleteStaff 
(
    @tcId varchar(11)
)
AS
BEGIN
    DECLARE @memId int;
SELECT @memId = staffId FROM staff WHERE TCid = @tcId;
DELETE FROM member WHERE memId = @memId;
END

The delete operation is done perfectly. But I got this error anyway. What would be your suggestion?

5
  • In the MSDN there is this note about an error 'parameter not supplied' Make sure that no BoundField controls in the data-bound control that you bind to the SqlDataSource control have names that match any parameter names in the DeleteParameters collection. Parameters that have the same name as bound fields are excluded from the SQL command, and a "parameter was not supplied" error might result. Could it be the case? Commented May 6, 2012 at 15:52
  • No, it didn't work too. As a result, I removed the procedure and I have tried to handle the execution by query. It works and then I continue my way. Commented May 6, 2012 at 15:59
  • why dont you use sql server profiler and check the queries that are sent for execution? Might get some information Commented May 6, 2012 at 16:15
  • 1
    Doesn't the parameter have to be prefixed with an @? Commented May 6, 2012 at 18:12
  • No DBM, it doesn't. When you assign a stored procedure parameter, you won't use '@' sign at the beginning. If you do, it will give exactly same error with this example. Commented May 7, 2012 at 13:00

1 Answer 1

2

If the delete operation is successful, the only way I can imagine this happening (especially since you haven't giving the details of the exception) is that there may be a trigger for delete that is calling another stored procedure that is failing.

Sign up to request clarification or add additional context in comments.

2 Comments

This is very meaningful answer. But there is no trigger but cascading. When a row in member table is deleted, 3 other tables are also affected. However, the related rows are also deleted.
Any delete triggers on those child tables?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.