Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
hi,

I want to execute alter script of stored procedure from c# code , does any one have any idea regarding this .

If you have any demo application then please paste with your answer.

Desperately Waiting for your replies.

Thanks in Advance.
Posted

1 solution

Just connect as usual, and issue an SQL ALTER command:
SQL
ALTER PROC [dbo].Sample
@Name varchar(100) OUTPUT
AS
BEGIN
SELECT @Name=Username FROM myTable WHERE iD=2
END
 
Share this answer
 
Comments
[no name] 1-Mar-12 23:21pm    
I want to execute this script by C#.
OriginalGriff 2-Mar-12 3:54am    
Yes. So?
As I said, connect as usual. Set that as your SqlCommand and issue a ExecuteNonQuery.
[no name] 5-Mar-12 23:10pm    
thanks.
[no name] 14-Mar-12 5:35am    
hi....if a sqlcommand executes properly it returns -1 , if an error occurs still it returns -1, how should i rollback if an error occurs ?

Thanks in Advance.
OriginalGriff 14-Mar-12 5:56am    
If an error occurs it generally throws an exception - use a try...catch block and Rollback in the catch block.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900