Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从按钮清除数据库中插入的数据_C#_Asp.net_.net_Sql Server - Fatal编程技术网

C# 如何从按钮清除数据库中插入的数据

C# 如何从按钮清除数据库中插入的数据,c#,asp.net,.net,sql-server,C#,Asp.net,.net,Sql Server,我在我的codebeard文件中引用了一个方法(botone): public partial class EnvianosTuCurriculum : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Boton

我在我的
codebeard
文件中引用了一个方法(
botone
):

public partial class EnvianosTuCurriculum : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        Botones botones = new Botones();
        botones.SaveCVInfo2(nombre.Text, Apellidos.Text, EmpleoS.Text, DireccionPersonal.Text, RadioButtonList6.SelectedItem.Text, contraseña.Text, TelHabi.Text, TelCel.Text, userEmail.Text, Nacionalidad.Text, LugarNaci.Text, FechaNac.Text, Edad.Text, Cedula.Text, EsCivil.Text, ProUofi.Text, Estatura.Text, Peso.Text, TipoSang.Text, RadioButtonList7.SelectedItem.Text, Lateralidad.Text, LicCond.Text, RadioButtonList5.SelectedItem.Text, MaMoVeh.Text, RadioButtonList4.SelectedItem.Text, EmpCta.Text, ProMens.Text, SuelAs.Text, RadioButtonList3.SelectedItem.Text, NomRec.Text, RadioButtonList2.SelectedItem.Text,Insti.Text, horario.Text, vivequien.Text, RadioButtonList1.SelectedItem.Text, otresp.Text, Ciudad.Text);
        Response.Redirect("Envia2.aspx");
    }

}
现在,若我添加另一个按钮
Button2
,我需要返回到上一页,并清除从这些控件发送到数据库的所有数据

我想我需要一个
if
语句,但我只需要添加一个
Response.Redirect(“previous_page.aspx”)
,不知道如何将数据清除到数据库中

使用
Response.Redirect
我可以返回,所有字段看起来都是空的,但我会再次开始填充它们,作为新用户,我不仅需要返回,还需要撤消插入db表中的所有数据


如何实现这一点?

我个人首先会添加验证器和任何其他相关控件,以确保输入的数据是正确的,和/或在将数据提交到数据库之前临时存储数据(这样可以避免删除数据)

但是,如果这不适用于删除SQL中的数据,那么您可能会遇到如下情况:

DELETE FROM table_name
WHERE some_column=some_value

查看此链接以获取更多信息/了解

您应该向SQL Server发出一条
DELETE
语句,其中包含与要删除的记录相关联的正确主键。谢谢!我刚刚通过使用PK ID列会话解决了这个问题,所以如果我返回,我可以编辑数据,并且数据会恢复到该会话中,但非常感谢!