ALTER PROCEDURE [dbo].[spCheckDupEmployee]
@empId int,
@empName varchar(100),
@empCode varchar(10),
@Message varchar(1000) OUTPUT
AS
SELECT @Message=""
BEGIN
SELECT * FROM Employee WHERE empName = @empName AND empId NOT IN(@empId)--AND cmpDeleteFlag = 0
IF @@ROWCOUNT > 0
BEGIN
SELECT @Message="Same Employee Name Exists!"
RETURN
END
SELECT * FROM Employee WHERE empCode = @empCode AND empId NOT IN(@empId)--AND cmpDeleteFlag = 0
IF @@ROWCOUNT > 0
BEGIN
SELECT @Message="Same Employee Code Exists!"
RETURN
END
RETURN
END
this checks duplication and sends back a message.
Now give this message string to a messagebox.show() method..
ex;
messagebox.show(msg,APPName);
1
solved How to show a error message if the data is already inserted in the database in c#