0
I have a txtEmail textbox in a Display() method where I assign you an email (via a query) so that I can display it in a user profile (all ok).
txtEmail.Text = item["email"].ToString();//devolve sapo.pt
But when I try to edit the value through the query, if I try to edit, always write me the value that had already been closed. any hints ?
SqlCommand cmd = new SqlCommand("UPDATE Utilizadores SET NomePessoal=@NomePessoal, nifPessoal=@nifPessoal, contacto=@contacto, email=@email WHERE (idLogin = @idLogin)", con);
cmd.Parameters.AddWithValue("@email", txtEmail.Text); // escrevo hotmail.com, mas fica na mesma com o valor sapo.pt
I do Binding like this
//Seleção do perfil
if (dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
txtid.Text = item["idLogin"].ToString();
txtNP.Text = item["NomePessoal"].ToString();
txtUT.Text = item["Utilizador"].ToString();
txtNif.Text = item["nifPessoal"].ToString();
txtCon.Text = item["contacto"].ToString();
txtTipo.Text = item["tipo"].ToString();
}
}
else
When you add the SQL parameter the value that is assigned is not the one in the
TextBox
?– João Martins
Supposedly yes , but as I above assign you a value query update with the value above and not the new one I wrote, I don’t know why
– Pedro Cardoso
If you do
debug
what value is in controltxtEmail
?– João Martins
The value is sapo.pt. I remove the action to the textbox above the Updtade works , only it does not display me (shows) the previous email (becomes empty the textbox)
– Pedro Cardoso
To
TextBox
is associated with anyBindingSource
?– João Martins
@Joãomartins edited above , that follows after the query
– Pedro Cardoso
@Joãomartins some hint?
– Pedro Cardoso
I’m still a little confused about how your code is... especially the code sequence. You can’t change the question and put the whole code (if it’s not too much)?
– João Martins