1

I have created a login form and the login details like username and password gets stored in xml database.

Now when a particular user wants to change his/her password. how to do that using xml database in C#. I don't have much idea on xml database. please help me out at the earliest.

Change password form looks like this

User name : 
Old password:
new password:
Confirm password:

Change(button)

when the user provides the necessary information and clicks the change button. the old password which gets stored in xml database should get replaced by the new password..

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

0

See how to change xml value file using c#

and How To Modify and Save XML with the XmlDocument Class in the .NET Framework

Community
  • 1
  • 1
Haris Hasan
  • 29,856
  • 10
  • 92
  • 122
0
private void btnLogIn_Click(object sender, EventArgs e)
    {
        if (checkBox_Remember.Checked)
                {
                    UpdateAppSettings_("Remember", "1");
                    UpdateAppSettings_("UserName", User.UserName);
                    UpdateAppSettings_("Password", password);
                }
    }
private void UpdateAppSettings_(string KeyName, string KeyValue)
    {
        XmlDocument XmlDoc = new XmlDocument();
        XmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
        foreach (XmlElement xElement in XmlDoc.DocumentElement)
        {
            if (xElement.Name == "appSettings")
            {
                foreach (XmlNode xNode in xElement.ChildNodes)
                {
                    if (xNode.Attributes[0].Value == KeyName)
                    {
                        xNode.Attributes[1].Value = KeyValue;
                    }
                }
            }
        }
        XmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
    }
star
  • 164
  • 1
  • 2
  • 13