Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Deleting user

Deleting user

Scheduled Pinned Locked Moved ASP.NET
helpquestioncsharp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bigphish
    wrote on last edited by
    #1

    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???

    R 1 Reply Last reply
    0
    • B bigphish

      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???

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • R R Giskard Reventlov

        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

        B Offline
        B Offline
        bigphish
        wrote on last edited by
        #3

        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 ?

        N 1 Reply Last reply
        0
        • B bigphish

          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 ?

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups