5
Answers

how to update the password of a particular email

Photo of Priya Jindal

Priya Jindal

9y
395
1
There are two text boxes.
textbox1.text contains the email id
textbox2.text contains the password which is to be updated .
these two textbxes are connected with the database. When a particular emailID is inserted in textbox1.text and password is wriiten then on click submit button the password will automatically gets updated into the database of that particular emailID. 
 
Please Help Me in this to write a code in "WINDOW BASED APPLICATION using c#.." 

Answers (5)

0
Photo of ali tuncer
NA 2.9k 108 9y

update syntax is wrong, you can't say SET WHERE..has to be this format :

UPDATE MyTable 
SET Columnn1 = somevalue
WHERE Column2 =somevalue
 
try this :
 
string sqlUpdate = "UPDATE login SET password='" + txtPass.Text  + "' where ID='" + txtID.Text  + "'"; 
  
0
Photo of Priya Jindal
NA 62 2.6k 9y
But Its not working
0
Photo of Priya Jindal
NA 62 2.6k 9y
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=HMS;Integrated Security=True");
if (txtPass.Text == txtConfrmPass.Text)
{
try {
string sqlUpdate = "UPDATE login SET WHERE password='" + txtPass.Text + "' where ID='"+txtID.Text+"'";
SqlCommand cmdd = new SqlCommand(sqlUpdate, conn);
conn.Open();
cmdd.ExecuteNonQuery(); 
conn.Close();
MessageBox.Show("successfully updated");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
else {
MessageBox.Show("retype your new password correctly");
}
0
Photo of Rahul Chavan
NA 1.2k 35.9k 9y
On submit click call SQL Update query
Update TableName set password="textbox2.text" where emailId="textbox1.text" 
 
Please apply validation for null and record exist in database before this query. 
0
Photo of ali tuncer
NA 2.9k 108 9y

you will use SQL Update statement :

http://www.w3schools.com/sql/sql_update.asp

when email is equal to particular email and password is not empty, execute update statement..