Ecrit par
rourou11 le vendredi 25 mai 2012 dans le thème :
C#
Bonjour,
je suis en train de créer une application web en asp.net. j'ai un probleme avec
la requete update je ne reussi pas a modifier le contenu de ma table sql server.
mon but c'est changer le mot de passe. voici le code:
SqlConnection con = new SqlConnection("Data Source=RABEB-PC;Initial
Catalog=vaccination;Integrated Security=True");
String cmdStr = "Select count(*)from authentification where
username='" + TextBox1.Text + "'";
SqlCommand Checkuser = new SqlCommand(cmdStr, con);
con.Open();
int temp =
System.Convert.ToInt32(Checkuser.ExecuteScalar().ToString());
if (temp == 1)
{
String cmdStr1 = "Select password from authentification where
username='" + TextBox1.Text + "'";
SqlCommand pass = new SqlCommand(cmdStr1, con);
String password = pass.ExecuteScalar().ToString();
if (password == TextBox5.Text)
{
String cmdStr2 = "UPDATE authentification SET password='"
+ TextBox6.Text + "',prenom='" + TextBox2.Text + "',nom='" + TextBox3.Text +
"',mail='" + TextBox4.Text + "' WHERE username='" + TextBox1.Text + "'";
SqlCommand dd = new SqlCommand(cmdStr2, con);
dd.ExecuteNonQuery();
con.Close();
Label1.Visible = true;
Label1.Text = "profil modifié";
}
else
{
Label1.Visible = true;
Label1.Text = "ancien mot de passe invalide";
}
}
SVP aidez moi à resoudre ce probleme c'est urgent. merci d'avance.
Classé sous : text,
con,
sqlcommand,
string,
password