Senthil Nathan.S

Hi

am Creating one web page in ASP.NET

and also implementing XML in my project am beginner to XML Creation

in my project i create XML document for every single Record in database table

I did this my level best

Its Run fine in local Environment

"But When i upload this page i can't get the XML document "

It will display the error like this "Access to the path 'C:\bay\passengers.xml' is denied."

"It doesn't create a XML file"

"In local Environment it works fine and also create every single record XML document"

This is my code for XML Creation

1  Sub WriteXMl()
2
3 Dim strCurrentPath As String = Request.PhysicalPath
4 Dim strXMLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "passengers.xml"
5 Dim strConnect As String
6 Dim objXMLWriter As XmlTextWriter
7 Dim dbReader As OleDbDataReader
8 Dim xmldoc As New XmlDocument
9 Dim objDataSet As New DataSet
10 Try
11 objXMLWriter = New XmlTextWriter(strXMLPath, Nothing)
12 Catch objError As Exception
13 Exit Sub
14 End Try
15
16 strConnect = WebConfigurationManager.ConnectionStrings("Webbay").ConnectionString
17 Dim objConnect As New OleDbConnection(strConnect)
18 Dim command As New OleDbCommand("SELECT PassengerNo,FirstName,LastName,Marketing FROM bay", objConnect)
19 objConnect.Open()
20 dbReader = command.ExecuteReader
21
22 objXMLWriter.Formatting = Formatting.Indented
23 objXMLWriter.Indentation = 3
24 objXMLWriter.WriteStartDocument()
25 objXMLWriter.WriteComment("Created on " & Now())
26 objXMLWriter.WriteStartElement("TRAMSDATA")
27 objXMLWriter.WriteElementString("Version", "0.10-2.07.00")
28 objXMLWriter.WriteStartElement("PROFILE")
29 While dbReader.Read()
30 objXMLWriter.WriteStartElement("PASSENGER")
31 objXMLWriter.WriteElementString("PASSENGERNO", dbReader("PassengerNo"))
32 objXMLWriter.WriteElementString("FIRSTNAME", dbReader("FirstName"))
33 objXMLWriter.WriteElementString("LASTNAME", dbReader("LastName"))
34 objXMLWriter.WriteElementString("MARKETING", dbReader("Marketing"))
35 objXMLWriter.WriteEndElement()
36 End While
37
38 objXMLWriter.WriteEndElement()
39 objXMLWriter.WriteEndElement()
40 objXMLWriter.Flush()
41 objXMLWriter.Close()
42 dbReader.Close()
43 objDataSet.DataSetName = "TRAMSDATA"
44 objDataSet.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "PASSENGER")
45 objDataSet.WriteXmlSchema(Request.MapPath("passengers.xsd"))
46
47 End Sub

Can You help me

Please Very Urgent

Thanks With Regards

S.Senthil Nathan



Re: ASMX Web Services and XML Serialization Access Denied For XML File

timvw

It seems that the user that is executing the code (i would presume <machine>\ASPNET) seems not to have the necessary rights to create/write the file... (So make sure you grant permissions to the ASPNET process to do so (and think about the possible consequences of that decision))





Re: ASMX Web Services and XML Serialization Access Denied For XML File

Anonymous

Do one thing, try to create the XML file in the same directory where your application is loaded. Because this is the only right issue. So try with this. I am not sure but try once.

Thanks

Bhavesh

78.bhavesh@gmail.com