Wednesday, 8 March 2017

CRUD Operations using Stored Procedure

  CRUD Operations using Stored Procedure

I. Enter into Database

      use Employee;

II.Create a StroredProcedure For CRUD Operations :

     here we need to declare input parameter which we are passing with '@' prefix to variable .

     Example: @Eid,@EName,@Dept,@Salary,@Action are input parameter.

create proc spCRUD
     @Action varchar(50),
     @Eid int ,
     @EName varchar(50),
     @Dept varchar(50),
     @Salary int


III.Action to Display Details of tblEmployee

   if @Action='Select'
begin 
select * from tblemployee;
end

IV.Action to insert values in tblEmployee

    if @Action='Insert'
begin 
insert into tblemployee values(@Eid,@EName,@Dept,@Salary);
end

V. Action to Update in tblEmployee

    if @Action='Update'
begin
update tblemployee set Eid=@Eid, Ename=@EName,Dept=@Dept,Salary=@Salary
         where Eid=@Eid;
end

 VI. Action to Delete in tblEmployee

    if @Action='Delete'
begin 
delete  from tblemployee where Eid=@Eid;
end 




VII. Display tblEmployee details with Stored Procedure 

 Resultant Set:

  

VIII. Insert Values in tblEmployee in Stored Procedure 

 

 Resultant Set:

 

IX. Update Values in tblEmployee in Stored Procedure

 

 Resultant Set:


X. Delete Values in tblEmployee in Stored Procedure

 

XI.Displaying Table Details 


Resultant Set:


Hope you all understand the CRUD Operation using  Stored Procodure  ..  


Do have any query regarding my code you can comment below !!! 



4 comments:

  1. Wooww Its !! very usefull ... Please keep updating the such posts. thanq

    ReplyDelete
  2. show this crud operations in asp.net zaffar .. waiting for your next blog !!

    ReplyDelete
    Replies
    1. Thanks juned in response to your requested query
      check out this post http://maddotnetcoder.blogspot.in/2017/03/aspnet-gridview-crud-operations-insert.html

      Delete
  3. This is good article and i found one article for CRUD operations with stored procedure. i hope you like this.

    ReplyDelete