Hi KrishnaManohar,
You can write a Stored Procedure for this. Set a primary key in your table.
If i want to insert a record into a Student table (UserName,Course,DOJ) values (@UserName,@Course,@DOJ). If primaykey is my username
ALTER PROCEDURE Example_SP
@UserName varchar(MAX),
@Course varchar(MAX),
@DOJ DateTime
AS
BEGIN
If NOT Exists(Select * from TableName where UserName = @UserName)
begin
Insert INTO TableName(UserName,Course,DOJ) values(@UserName,@Course,@DOJ)
return 1;
end
else
begin
return -1;
end
END
GO
In the aspx page, catch the return value from the StoredProcedure into a return value parameter. Check if its value is 1 then we can show record inserted succesful msg or record already exists message.
Regards,
Awesome Coding !! :)
Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator