mercredi 5 juin 2019

Invalid postback or callback argument. why my code doesnt work?

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?

protected void button1_Click(object sender, EventArgs e)
{
    string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data 
Source=" + 
System.Web.HttpContext.Current.Server.MapPath(@"DataBase\Users.accdb");
    string Query = "update Users.users set (aid,email) (id='" + 
id_txt.Value.ToString() + "',email='" + email_txt.Value.ToString() + "' 
where id='" + id_txt.Value.ToString() + "' ;";
    System.Data.OleDb.OleDbConnection con = new 
System.Data.OleDb.OleDbConnection(strConnection);
    System.Data.OleDb.OleDbCommand cmd = new 
System.Data.OleDb.OleDbCommand(Query, con);
    System.Data.OleDb.OleDbDataReader myReader;
    try
    {
        con.Open();
        myReader = cmd.ExecuteReader();
        while (myReader.Read())
        {

        }
    }
    catch (Exception ex)
    {
    }
}




Aucun commentaire:

Enregistrer un commentaire