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

i want a single stored procedure for insertion ,updation and deletion into a data grid viewu
thank yo
Posted
Comments
P.Salini 15-Mar-12 1:49am    
what you have tried and where you are getting problem

Hi, you can use one stored procedure for all Actions.

write a sp with all possible parameters and assign value null to every parameter.

i.e.

SQL
Create procedure spUser
@ActivityType bigint = null,
@Uname varchar(50) = null
As
Begin
 if @ActivityType  = 1
 Begin
   -- Insert
 End
 if @ActivityType  = 2
 Begin
   -- Update
 End
 if @ActivityType  = 3
 Begin
   -- delete
 End
End


I am using this, if you have any problem with this then tell me. :-)
 
Share this answer
 
v2
Comments
satya praveen 15-Mar-12 2:26am    
hihow do we declare the activitytype in the code
Sarvesh Kumar Gupta 15-Mar-12 13:32pm    
it is user defined, you can send 1 for Add, 2 for edit, 3 for delete and so on.
there is @ActivityType parameter is urgent and other parameters are optional.
 
Share this answer
 
Hi,

you can create more than one stored procedure with similar name using ";" section no.
i.e.
SQL
sproc_User;1 --FOR ADD
sproc_User;2 --FOR EDIT
sproc_User;3 --FOR DELETE
sproc_User;4 --FOR LIST


in the above case you main stored procedure will be 1 named "sproc_User"
 
Share this answer
 

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