private void btn_Submit_Click(object sender, EventArgs e)
{
if (txt_UserName.Text == "" || txt_Password.Text == "")
{
MessageBox.Show("Please provide UserName and Password");
return;
}
try
{
SqlCommand cmd = new SqlCommand("UPDATE tbl_Login SET Password=@password where UserName=@UserName ", cs);
cmd.Parameters.AddWithValue("@UserName", txt_UserName.Text);
cmd.Parameters.AddWithValue("@password", txt_Password.Text);
cs.Open();
SqlDataAdapter adapt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapt.Fill(ds);
cs.Close();
int count = ds.Tables[0].Rows.Count;
if (count == 1)
{
MessageBox.Show("Password Changed Successfully!");
}
else
{
MessageBox.Show("Password Changed Failed!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}