I'd like to update my XML file. At least 1 field from 1 record. Is this possible without saving the whole file all over?
This is my code :
This is my code :
Code:
private sub getPassword_Click(obj as Object, e as EventArgs)
if not (Page.IsValid) Then
Msg.Text = "Some required fields are invalid."
return
end if
'Check if e-mail is in the database, so if user exists
dim cmd as String = "UserEmail='" + UserEmail.Value + "'"
dim ds as DataSet = new DataSet()
dim fs as FileStream = new FileStream(Server.MapPath(userFile),FileMode.Open,FileAccess.Read)
dim reader as StreamReader = new StreamReader(fs)
ds.ReadXml(reader)
fs.Close()
dim users as DataTable = ds.Tables(0)
dim matches as DataRow() = users.Select(cmd)
dim DBNull As Object = Convert.DBNull
if not (matches Is Nothing) AND matches.Length > 0 Then
'If user exists :
dim newPassword as string
newPassword = GeneratePassword(8)
dim test as boolean
'send mail to users with their new password
dim objEmail as New MailMessage()
objEmail.To = UserEmail.Value
objEmail.From = "test@test.be"
objEmail.Subject = "Test mail"
objEmail.Body = "newPassword"
SmtpMail.SmtpServer = "mail-out.pandora.be"
try
SmtpMail.Send(objEmail)
Response.Write("Your E-mail has been sent successfully - Thank You")
test = True
catch exc as Exception
Response.Write("Send failure: " + exc.ToString())
test = False
End Try
if test Then
'if the mail was sent, add the new password to the xml file
dim row as Datarow = matches(0)
?????????????????????????????
else
end if
Response.Redirect("../Logon.aspx")
else
'If user-mail is not in the xml-file
Msg.Text = "E-mail does not exist."
end if
end sub