I need your help please. This is my second day making a simple
registration form and it still didn't work. It simply get the information
from the form, and save them to an XML file. Can't be simpler, but I'm
still having problems especially
after uploaded the app to a host server. I think that the error is related
to the file path. I tried every possible way to do it, and after it worked
fine on my local host it didn't work in the remote host.
Please guys, I have to submit it by the end of the day
Please check out this code:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim XMLFile As String = Request.ApplicationPath & "/Table1.xml"
' this line didn't work on local host, I used:
Request.PhysicalApplicationPath instead of ApplicationPath. Both ways
didn't work on the remote host.
Dim DS As New Dataset1()
Try
DS.ReadXml(XMLFile, XmlReadMode.IgnoreSchema)
Catch Exp As IO.IOException
End Try
Dim DT As DataTable = DS.Tables(0)
Dim DR As DataRow = DT.NewRow()
With DR
.Item(0) = txtEmail.Text
If rblTitle.SelectedIndex <> -1 Then
.Item(1) = rblTitle.SelectedItem.Value
Else
.Item(1) = ""
End If
.Item(2) = txtFirstName.Text
.Item(3) = txtLastName.Text
.Item(4) = txtTelephone.Text
.Item(5) = txtMobile.Text
.Item(6) = txtPOBox.Text
.Item(7) = txtCity.Text
.Item(8) = txtPostalCode.Text
.Item(9) = CDate(ddlDay.SelectedItem.Value & "\" &
ddlMonth.SelectedItem.Value & "\" & ddlYear.SelectedItem.Value)
End With
Try
DT.Rows.Add(DR)
DS.AcceptChanges()
DS.WriteXml(Request.MapPath(Request.ApplicationPath)
& "\Table1.xml", XmlWriteMode.WriteSchema)
Response.Redirect("RegSuccess.htm")
Catch Exp As ConstraintException
Response.Redirect("Duplicate.htm")
End Try
DT.Dispose()
DS.Dispose()
End Sub
Best Regards