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