Results 1 to 3 of 3

Thread: ASP.NET-Delete or desactivate a membership account from a Database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2011
    Posts
    26

    ASP.NET-Delete or desactivate a membership account from a Database

    I have a table in my database called users, have created a Cancel Membership button so that a registered user would be able to cancel his membership whenever he wants.

    How do i achieve this.My database has a table called users with fields - FirstName, LastName, EMail,Password. Users normally login with their Email and password details. So please i need a code that will be behind the Cancel Membership button and NOT only explanations.

    This is the code i used behind my Cancel Membership button but it does not seem to work:

    Code:
    Protected Sub btnCancelMem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancelMem.Click 
     
     
            'var to store the email address 
            Dim EMail As String = txtEMail.Text 
            'var to store the password 
            Dim Password As String = txtPassword.Text 
            'connect to the database table selecting records matching this email    address and password 
            Dim ThisUser As New DatabaseTable(ThisSite.DatabaseName, "delete from users where email='" & EMail & "' and UserPassword='" & Password & "'", "#PN", "#PW") 
            
             
        End Sub.

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: ASP.NET-Delete or desactivate a membership account from a Database

    Im not sure why if you have created a database and membership pages you don't know how to delete a record from the database.

    Rather than someone just posting code, you really need to learn ado.net . The steps would be

    create a connection to the database
    create a command object to execute the query
    for a delete statement you would use myCommand.executeNonQuery
    close the connection

    Lastly you should always use "parameters" to supply values to the query, never place user input directly into the query text - see sql injection attack.

    This is a good place to start
    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx

    Following links on that page, here is executing a command
    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ASP.NET-Delete or desactivate a membership account from a Database

    Also, where is the type DatabaseTable coming from?

    I don't recognise that at all?!?

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width