Home > Forum > ASP.NET > .

.

by Dave   on Sep 28, 2013   Category: ASP.NET  |  Views: 1281    |  Points: 5   |  Starter 
  Reply
.

Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :.   
by Thamil
on Sep 30 2013 12:01PM
Points : 10
Gold 
Hello Dev,

i have updated the stored proc below pls check & let me know if anything

ALTER PROC [dbo].[SP_Customer]        
(
@pvchCustId int =0,
@pvchCustName varchar(100)=null,
@pvchustaddress1 varchar(100)=null,
@pvchustaddress2 varchar(100)=null,
@pvchCustPhone varchar(100)=null,
@pvchCustEmail varchar(100)=null,
@pvchCreatedBy varchar(100)=null,
@pvchAction varchar(50)=null,
@pIntErrDescOut int output
)
AS
BEGIN
set @pIntErrDescOut=0;
if(@pvchAction='select')
begin
SELECT CUSTID,CUSTNAME,CUSTNAME,CUSTADDRESS1,CUSTADDRESS2,CUSTPHONE,
CUSTEMAIL,ACTIVE FROM tblCustomer WHERE Active=1;
end
else if(@pvchAction='insert')
begin
if not exists(select * from tblCustomer where CustName=@pvchCustName or CustEmail=@pvchCustEmail)
begin
INSERT INTO tblCustomer(CustName,Custaddress1,Custaddress2,CustPhone,
CustEmail,Createdby,CreatedDt,Active)VALUES(@pvchCustName,@pvchustaddress1,@pvchustaddress2,@pvchCustPhone,
@pvchCustEmail,@pvchCreatedBy,GETDATE(),1);
end
else
begin
set @pIntErrDescOut=2
end

end
else if(@pvchAction='update')
begin
UPDATE tblCustomer SET CustName=@pvchCustName,Custaddress1=@pvchustaddress1,Custaddress2=@pvchustaddress2,
CustPhone=@pvchCustPhone,CustEmail=@pvchCustEmail,Updatedby=@pvchCreatedBy,UpdatedDt=GETDATE()
WHERE CustID=@pvchCustId;
end
else if(@pvchAction='delete')
begin
UPDATE tblCustomer SET Active=0,Updatedby=@pvchCreatedBy,UpdatedDt=GETDATE()
WHERE CustID=@pvchCustId;
end

IF (@@ERROR <> 0)
BEGIN
SET @pIntErrDescOut = 1
END
END

Recent Post

Latest Posts