Running stored procedure within a stored procedure

I have a custom built users table for storing some values and I am also utilizing the aspnet_Users table. I want to delete a user from my users tables then execute the aspnet_Users_DeleteUser sproc and pass into the stored procedure the username of the user to delete because the DeleteUser method requires this. When I execute the command from within my web application I get the exception below. Both values are being obtained from the application and are represented in my DAL that is also below. Any thoughts as to why I am receiving this exception? Thanks.

Procedure or function 'aspnet_Users_DeleteUser' expects parameter '@UserName', which was not supplied.


public static bool DeleteUser(int userID, string username)


int result = 0;using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))


SqlCommand myCommand = new SqlCommand("Users_DeleteUser", myConnection);

myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.AddWithValue("@UserID", userID);

myCommand.Parameters.AddWithValue("@UserName", username);




result = myCommand.ExecuteNonQuery();



catch (Exception ex)


throw new Exception("There was a problem attempting to connect to the database to delete the record. {0}", ex);



return result > 0;


5/9/2008 3:28:57 PM 91979 articles. 4 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 20

whats your exception?


HAAAA sorry i didnt see it the first time.

well it looks like youre passing your param to your first proc and its working great but your nested proc needs the param, so maybe you can use a different variable and pass it as well or your procedure youre calling first is getting rid of the parmeter before your nested param can use it, if you cant figure it out maybe seeing the params for your procs would help or seeing how you handle your params in your procs, any who its getting rid of that param for your SECOND proc. i dont know if this helps you probabloy already know that but..... you can also print out your procedure instead of actually running it or execute it statically with param values you know and watch what it does, instead of calling it from code. then you know its your procedure and not your code. holla? cool let me know if i sucked at helping you or if i can help anymore..... actually dont tell me if i suck it will hurt my feelers

my friends call me MOI
5/9/2008 4:19:44 PM

Here is the sproc. When I execute the query and pass in a UserID and UserName, it still comes up with the error which is leading me to believe that there is a problem with my sproc.

ALTER PROCEDURE [dbo].[Users_DeleteUser]


@UserID int,

@UserName nvarchar(50)





--Delete the user from the user table


--Delete the user from the Users ASPNET table

EXEC dbo.aspnet_Users_DeleteUser @UserName


--If we reach here, success!




--There was an error



--Raise an error with details of exception

DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int


RAISERROR(@ErrMsg, @ErrSeverity, 1)


5/9/2008 4:55:21 PM

EXEC dbo.aspnet_Users_DeleteUser @UserName


that line needs @userid from what i can tell.... so something in there must be tryign to use @userid

my friends call me MOI
5/9/2008 8:24:20 PM

Similar Artilces:

Running a stored procedure within a stored procedure
I have a stored procedure (A), which I need to call from another stored procedure (B). The data pulled from (B) is then inserted into a temporary table. The problem I am having is the stored procedure is in a loop, and it only runs once. I need it to run each time the statement loops. For example: In the cursor I have, there are 3 rows, so the statement should return 3 rows. However, only 1 row is returned, it looks like the stored procedure is only one once. What do I have to do to get it to loop?? DECLARE dCURSOR CURSOR FOR select ID, value1, value2 from table; OPEN dCU...

get result set from stored procedure within a stored procedure
Dear All, Would someone tell me how to get result set from stored procedure within a stored procedure? I am testing ASE on linux. In MSSQL Server 6.5 or above, the insert statement can insert result set from stored procedures, i.e. insert into #temp_table execute my_store_proc @val1, @val2.. In SQLAnywhere 5.0 or above, cursor can be declared on procedures, i.e. declare my_cur cursor for call my_store_proce(@val1, ...); Once cursor is declare, rows can be fetched into a temp table. But these two approaches do not work in You have to write the ...

Is the transaction context available within a 'called' stored procedure for a transaction that was started in parent stored procedure?
I have  a stored procedure 'ChangeUser' in which there is a call to another stored procedure 'LogChange'. The transaction is started in 'ChangeUser'. and the last statement in the transaction is 'EXEC LogChange @p1, @p2'. My questions is if it would be correct to check in 'LogChange' the following about this transaction: 'IF @@trancount >0 BEGIN Rollback tran' END Else BEGIN Commit END.  Any help on this would be appreciated.sun21170  In case of nested stored procedures, it would be better to return a value from called...

stored procedure. The c# code run stored procedure.
 CREATE PROCEDURE GetThreadMessages @iThreadID int AS SELECT message_id, thread_id, user_id, first_names, last_name, email, subject, body, date_submitted, category_name, category_id, last_edited FROM message_view WHERE thread_id = @iThreadID ORDER BY date_submitted asc For update ---------------------------------------------------------------------------------------- CREATE PROCEDURE UpdateThreadMessages @iThreadID int @name varchar(50) AS UPDATE message_view SET first_names = @name FROM message_view ...

calling another stored procedure within a stored procedure?
Hi, I have a while loop stored procedure, I need to send email for each item in the loop using a sendemail stored procedure. I have two question .. 1) I use EXEC PRODUCTION.DBO.SENDMAIL '', 'Start', 'Job Start' in side the while loop stored procedure, but i didn't get any email or error msg. Why? 2) I try to move a file .. how do I find out if the moving is completed successfully? -- MOVE FILES  SET @CMD = 'MOVE /Y ' + '"' + @ORIGINAL_FILE + '"' + ' "' + @MOVE_FILE + '"' EXEC master.dbo.xp_cmdshell @CMD   Thanks for your reply in advance. 1. I hav...

Calling a stored procedure inside another stored procedure (or "nested stored procedures")
Hi all - I'm trying to optimized my stored procedures to be a bit easier to maintain, and am sure this is possible, not am very unclear on the syntax to doing this correctly.  For example, I have a simple stored procedure that takes a string as a parameter, and returns its resolved index that corresponds to a record in my database. ie exec dbo.DeriveStatusID 'Created' returns an int value as 1 (performed by "SELECT statusID FROM statusList WHERE statusName= 'Created')  but I also have a second stored procedure that needs to make reference to&n...

Execute stored procedure from stored procedure
Hello,i need to execute a stored procedure from another stored procedure. For example:StoredProcedure1: Returns a table with columns "year" and "value".StoredProcedure2: Also returns a table with columns "year" and "value".In Stored Procedure3: I would like to use the results from StoredProcedure1 and StoredProcedure2 and join them. Can somebody give me an example how to execute a stored procedure from another one and use the result table for a new command?Kind regards and thanks,carsaw hi,first off all let me clarify here - you cannot return ta...

calling a stored procedure from a stored procedure
Hi Group! I'm on ASA 8.02 Build 4411 writing sprocs in WATCOM SQL. I have a sproc which breaks a given string-parameter into pieces. It's result set contains the pieces, e.g. last line of sproc: "select item from mytable;". This sproc works fine. Now I need to call this procedure from another procedure which has a variable result set. I tried the following: <snip... set ll_retval = 0; call sp_breakstring(as_bzp,','); BreakLoop: while ll_retval <> 100 and not ll_retval < 0 loop set li_zaehler = li_zaehler + 1; fetch next sp_breakstrin...

Calling a Stored Procedure from a Stored Procedure
Can you do this? I have a sp that returns a list of eligible accounts and then I use that list in other sp but I don't want to keep copying the code, I would like to be able to use it as a sub query in other sp but I don't know if this is possible or what the syntax would be. Thanks, Aaron You cannot do that directly. You can: 1. Use User defined functions which can return a resultset 2. Use a local #temp table which can hold the resultset of the called stored procedure and use this #temp table in your subsequent processing INSERT #tempTable EXEC s...

Using ADO.NET Execute Second Stored Procedure Depending of Output of First Stored Procedure
When a user logs onto the app, I capture their UserId, today's date and thier WINNT using ADO.NET calling a stored procedue-no problem. Now, once the above mention fields have been populated, when the same user logs on again and this time click their daily attendance time, I need to execute and update stored procedure-no problem. Each time the user logs onto the attendance page, they need to be able to view the previuos time stamps, on page load.- no problem The problem is that I cannot get all three to work in concert, although they will work independently, somewhat. Sotred proc...

Calling Stored Procedure fromanother Stored Procedure
Hi,I am getting error when I try to call a stored procedure from another. I would appreciate if someone could give some example.My first Stored Procedure has the following input output parameters:ALTER PROCEDURE dbo.FixedCharges @InvoiceNo int,@InvoiceDate smalldatetime,@TotalOut decimal(8,2) outputAS .... I have tried using the following statement to call it from another stored procedure within the same SQLExpress database. It is giving me error near CALL.CALL FixedCharges (@InvoiceNo,@InvoiceDate,@TotalOut )Many thanks in advanceJames I believe you want to use 'EXEC' abad...

how to call stored procedure from another stored procedure?
is it possible to call a stored procedure from another stored procedure?-keeara g------------------ Inside your first Stored Procedure: exec <name of SP to run> <Eventual Parameters this SP requires> Here is a link to all you want to know about executing SPs from other SPs. You can even Execute SPs on other SQL Servers.RegardsAndre Colbiornsen ---------------------------------Seventh DayRåbygatan 1A,SE-223 61 LundSwedenMob.: +46-(0)708-97 78 79Mail:

Calling stored procedure from another stored procedure
Is it possible to call one sp from another sp?I've been hunting around for an example to do this and just can't seem to find one.Anyone have a link for this or a sample?Thanks all,Zath Yes, you can. Just use EXEC usp_secondStoredProc @params inside your first SP.Nick...

Call as stored procedure from another stored procedure
I am using a stored procedure (SP_A) to insert rows to a table. This is done by the cursor within the procedure. Value for one of the column is provided by SP_B. My problem is that when i call SP_B in SP_A it does not return any value (rather i do not know how to capture it from SP_A). If executed individually it returns a value. Please help with example if something specific needs to be taken care. Suresh wrote: > > Please help with example if something specific needs to be > taken care. Please always post the version and build number of ASA that you are using (e....

Web resources about - Running stored procedure within a stored procedure -

Parliamentary procedure - Wikipedia, the free encyclopedia
... of the House of Commons of the Parliament of the United Kingdom , from which it derives its name. In the United States, parliamentary procedure ...

Procedure is more a snap than a snip
A QUEENSLAND doctor is bidding to set an unusual world record by performing the highest number of vasectomies in one day, with the help of fellow ...

Will Paul Ryan Make His Mark As Speaker By Instituting Impeachment Procedures Against President Obama ...
Wisconsin Ayn Rand devotee Paul Ryan just started his new job as Speaker of the dysfunctional House Republicans. And he's already headed for ...

Are patients charged drastically different prices for the same medical procedure? - Videos - CBS News ...
Patients are often charged drastically different prices for the same medical procedures and research may link later bedtimes with gaining weight. ...

Vin Scully To Miss Dodgers Postseason After Medical Procedure
... , who has been calling Dodgers games since the Truman administration, will miss the team’s playoff run as he recovers from a medical procedure. ...

'Painless' dental cavity procedure regrows tooth enamel
... "cavity" a lot of people sweat thinking about painful injections and relentless drilling. But scientists in Britain have developed a new procedure ...

Kim Zolciak Shares Glam Post-Heart Surgery Selfie, Calls Procedure 'a Success'
Kim Zolciak Shares Glam Post-Heart Surgery Selfie, Calls Procedure 'a Success'

Wall Street Regulator (FINRA): Procedures, Recordkeeping, Education Key For Compliant Social Media
Meeting regulatory requirements when using social media requires proper procedures, recordkeeping solutions, sufficient resources to monitor ...

US AIRPORT SECURITY CONCERNS DHS to heighten procedures in light of Russian jet bombing theory, poor ...
US AIRPORT SECURITY CONCERNS DHS to heighten procedures in light of Russian jet bombing theory, poor test performances by TSA screeners

Concession: Ryan promises Freedom Caucus he’ll delay discussion of reforming procedure for removing the ...
Compromise. Like I said this morning, it sounds like they did a little horse-trading at their summit. Ryan wants them to give up their right ...

Resources last updated: 11/27/2015 6:55:35 PM