Deleting user
-
Hi.. I have an issue with the User table..How can I prevent a user deleting himself? I am giving the procedure below:
ALTER PROCEDURE [dbo].[Usp_User_Delete]
@LoginID AS int,
@DeletingPersonLoginId AS int,
@ErrorMessage as varchar(100) OUTPUT
AS
BEGIN
SET @ErrorMessage = 'SUCCESS'BEGIN TRY DELETE FROM \[tbl\_User\] WHERE ID = @LoginID and ID<>@DeletingPersonLoginId END TRY BEGIN CATCH SELECT @ErrorMessage = ERROR\_MESSAGE() END CATCH
What I have to check in C# code before delete command firing???
-
Hi.. I have an issue with the User table..How can I prevent a user deleting himself? I am giving the procedure below:
ALTER PROCEDURE [dbo].[Usp_User_Delete]
@LoginID AS int,
@DeletingPersonLoginId AS int,
@ErrorMessage as varchar(100) OUTPUT
AS
BEGIN
SET @ErrorMessage = 'SUCCESS'BEGIN TRY DELETE FROM \[tbl\_User\] WHERE ID = @LoginID and ID<>@DeletingPersonLoginId END TRY BEGIN CATCH SELECT @ErrorMessage = ERROR\_MESSAGE() END CATCH
What I have to check in C# code before delete command firing???
If you don't want the user to be able to delete themselves why offer the ability to do so?
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
If you don't want the user to be able to delete themselves why offer the ability to do so?
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Sorry..I forget to mention, there are two type of users ..Admin_user and user.. some conditions has to be satisfied: 1.adminUser can only delete other users. 2.Atleast one adminuser should be there in the table always. is there any way in sql ?
As digi man said, don't allow the option. You should have some idea which user is executing the command, you can tell if they are admin or not, so just don't allow that user ID to be used, or don't show it in your list.
I know the language. I've read a book. - _Madmatt