mardi 11 juin 2019

Syntax error in UPDATE statement. What is wrong with the code?

I am trying to update my data base from the web but it doesnt work and I dont know why. it says: "Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation." what do I need to do?

string MySQL = @"UPDATE users 
             (email, pname, accountname, pid, age, passw) 
             Set(@email, @pname,@account,@pid, @age, @passw) where 
(id='"+Request.Form["id"]+"')";
    string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data 
Source=" + 
System.Web.HttpContext.Current.Server.MapPath(@"DataBase\Users.accdb");
    using(System.Data.OleDb.OleDbConnection con = new  
System.Data.OleDb.OleDbConnection(strConnection))
    using(System.Data.OleDb.OleDbCommand cmd = new  
System.Data.OleDb.OleDbCommand(MySQL, con))
    {
        con.Open();
        cmd.Parameters.Add("@email",  
System.Data.OleDb.OleDbType.VarWChar).Value = Request.Form["email"];
        cmd.Parameters.Add("@pname",  
System.Data.OleDb.OleDbType.VarWChar).Value = Request.Form["pname"];
        cmd.Parameters.Add("@account",  
System.Data.OleDb.OleDbType.VarWChar).Value = Request.Form["accountname"];
        cmd.Parameters.Add("@pid",  
System.Data.OleDb.OleDbType.VarWChar).Value = Request.Form["pid"];
        cmd.Parameters.Add("@age",  
System.Data.OleDb.OleDbType.VarWChar).Value = Request.Form["age"];
        cmd.Parameters.Add("@passw",  
System.Data.OleDb.OleDbType.VarWChar).Value = Request.Form["passw"];
        cmd.ExecuteNonQuery();
        con.Close();
    }
    Response.Redirect("showalldata.aspx");

Aucun commentaire:

Enregistrer un commentaire