Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to delete user data from table whenever user login his/her email stored in session so i want to perform that if user click on delete button then through session it deleted his/her data from table so is it possible or not? if it is then how please describe me through code.
Posted
Comments
So when delete is clicked, run a query and delete all user related records. Where is the issue?
Member 12059614 21-Oct-15 6:42am    
There is error occurred when i declare session name in code.
My code is like this:
cn.Open()
Dim query As String
query = "delete * from tabdata where email='" + Session + "'"
Try
MsgBox("Account deleted succsessfully")
Response.Redirect("Homepage.aspx")
Catch ex As Exception
Response.Write("<script>alert('" + ex.ToString() + "');</script>")
End Try
End Sub

You must be storing data table as a object in session. so when you click button is clicked, you again put the new modified object for data table in session. That means remove it from session and add it again
 
Share this answer
 
Quote:
query = "delete * from tabdata where email='" + Session + "'"
That should be Session["Email"] or something like that, not Session.

Also use parameterized query instead of concatenation, otherwise it will be prone to SQL injection attacks.
 
Share this answer
 
Use
delete from tabdata where email='" + Session["EmailSession"].ToString() + "'"

That should be Session["EmailSession"] is your email session name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900