2013-06-28 1 views
0

Quelque chose ne va pas avec mon code ici sur Visual Studio 2012. Il est censé mettre à jour les enregistrements qui peuvent être trouvés sur mon SQL Server Management Studio. Tout est cohérent avec la base de données sauf pour cette mise à jour. S'il vous plaît jeter un oeil à mon code:Données sur SQL Server Management Studio ne met pas à jour

protected void btnUpdate_Click(object sender, EventArgs e) 
    { 
     con.Open(); 
     SqlCommand cmd = new SqlCommand(); 
     cmd.Connection = con; 
     if (txtPassword.Text == "") 
     { 
      cmd.CommandText = "UPDATE Users SET [email protected], [email protected], " + 
       "[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] " + 
       "WHERE [email protected]"; 
     } 
     else 
     { 
      cmd.CommandText = "UPDATE Users SET [email protected], [email protected], [email protected], " + 
       "[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] " + 
       "WHERE [email protected]"; 
     } 
     cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar).Value = txtEmail.Text; 
     cmd.Parameters.Add("@Password", SqlDbType.NVarChar).Value = Helper.CreateSHAHash(txtPassword.Text); 
     cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = txtFN.Text; 
     cmd.Parameters.Add("@LastName", SqlDbType.VarChar).Value = txtLN.Text; 
     //cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = txtAddress.Text; 
     cmd.Parameters.Add("@Street", SqlDbType.NVarChar).Value = txtStreet.Text; 
     cmd.Parameters.Add("@Municipality", SqlDbType.NVarChar).Value = txtMunicipality.Text; 
     cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value = txtCity.Text; 
     cmd.Parameters.Add("@ZipCode", SqlDbType.NVarChar).Value = txtZipCode.Text; 
     cmd.Parameters.Add("@ContactNo", SqlDbType.NVarChar).Value = txtContact.Text; 
     cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = Session["UserID"].ToString(); 
     if (fuImage.HasFile) 
     { 
      cmd.Parameters.Add("@Image", SqlDbType.Text).Value = "~/images/" + fuImage.FileName; 
      fuImage.SaveAs(Server.MapPath("~/images/" + fuImage.FileName)); 
     } 
     else 
     { 
      cmd.Parameters.Add("@Image", SqlDbType.Text).Value = imgAvatar.ImageUrl; 
     } 

     Helper.AddLog(Session["UserID"].ToString(), "Update", "Updated a User"); 
     Response.Redirect("Default.aspx"); 
    } 

    protected void btnCancel_Click(object sender, EventArgs e) 
    { 
     Response.Redirect("Default.aspx"); 
    } 
+0

Vous ne lancez pas la commande –

Répondre

2

Vous avez oublié d'exécuter la requête

cmd.ExecuteNonQuery(); 
0

Votre manquent

cmd.ExecuteNonQuery(); 
Questions connexes