且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从会话中存储的表中删除数据

更新时间:2023-02-07 11:42:34

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


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.