Hi fareed.fd7,
You need to create a procedure like below where you are checking the personName and UserName exists or not if exists return true if not then update the record
SQL
CREATE PROCEDURE CheckUserNameAndPersonName
@UserName VARCHAR(50)
,@PersonName VARCHAR(50)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Exists VARCHAR(20)
IF EXISTS(SELECT UserName,PersonName
FROM YourTableName
WHERE YourUserNameColumn = @UserName
AND YourPersonNameColumn = @PersonName)
BEGIN
SET @Exists = 'exists'
END
ELSE
BEGIN
--Your Update Statement Comes Here
SET @Exists = 'not exists'
END
RETURN @Exists
END
Once the statement gets executed then you need to check returned value from stored procedure if it returned exists then show the msg if returned not exists then show the recorded updated msg like below
object returnedValue = cmd.ExecuteScalar();
if(returnedValue.ToString() == "exists")
{
//Your Message Comes of Record Already Exists;
}
else
{
//Your Record Updated msg comes here;
}
You need to implement above logic according to your requirement