如何从会话中存储的表中删除数据 [英] how to delete data from table which is stored in session

查看:85
本文介绍了如何从会话中存储的表中删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望每当用户登录他/她在会话中存储的电子邮件时从表中删除用户数据,所以我想执行该操作,如果用户点击删除按钮然后通过会话它从表中删除他/她的数据是否可能?如果是那么请通过代码描述我。

解决方案

您必须将数据表存储为会话中的对象。因此,当您单击单击按钮时,您再次将新修改的对象放入会话中的数据表。这意味着将其从会话中删除并再次添加


Quote:

query =delete * from tabdata where email ='+ Session +'

那应该是Session [Email]或类似的东西,而不是Session。



也可以使用参数化查询而不是连接,否则会容易发生SQL注入攻击。


使用

从tabdata删除其中email = '+ Session [EmailSession]。ToString()+'



应该是Session [EmailSession]是您的电子邮件会话名称。


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.

解决方案

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


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.


Use

delete from tabdata where email='" + Session["EmailSession"].ToString() + "'"


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


这篇关于如何从会话中存储的表中删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆