Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database to xml

Status
Not open for further replies.

aamaker

Programmer
Jan 20, 2002
222
US
Im trying to figure out how to take a simple access db table and create an xml file... any one have an example of how to pull this off-- im using classic asp and running IIS using dw8
 
Thanks for the reply... Im getting what looks like a permissions related issue, but I've already modified permissions to allow write...

heres the error I get:

Error Type:
Microsoft JET Database Engine (0x80004005)
Could not find installable ISAM.
....../testxml.asp, line 20



heres the code Im using (based almost entirely on the example you referred to in your post:

Code:
<html>
<title>CodeAve.com(Create XML from Access)</title>
<body bgcolor="#FFFFFF">
<%
' Name of the access db being queried
accessdb="sitessearchdatabase" 

' Connection string to the access db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\MyLocalProductionServer\database\sitessearchdatabase.mdb;"


' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Query the states table from the state_info db
sql = "select * from Tbl_BuildingData" 

' Execute the sql
rs.Open sql, cn

' Move to the first record
rs.MoveFirst

' Name for the ouput document 
file_being_created= "buildings.xml"

' create a file system object
set fso = createobject("scripting.filesystemobject")

' create the text file - true will overwrite any previous files
' Writes the db output to a .xml file in the same directory 
Set act = fso.CreateTextFile(server.mappath(file_being_created), true)

' All non repetitive xml on top goes here
act.WriteLine("<?xml version=""1.0""?>")
act.WriteLine("<Buildings>")

'Loop to output all the query results to the xml document
do while not rs.eof

' counter to give each record a sequential listing
counter=counter+1

act.WriteLine("<Building id="""& counter &""">")
act.WriteLine("<DBid>" & rs("ID") & "</DBid>" )
act.WriteLine("<Building_name>" & rs("name") & "</Building_name>" )
act.WriteLine("<SqFeet>" & rs("SqFeet") & "</SqFeet>")
act.WriteLine("<County>"& rs("county") & "</County>")
act.WriteLine("<YrBuilt>"& rs("YrBuilt") & "</YrBuilt>")
act.WriteLine("</Building>")

' move to the next record
rs.movenext
loop

' All non repetitive xml on bottom goes here
act.WriteLine("</Buildings>")


' close the object (xml)
act.close


' Writes a link to the newly created xml document in the browser
response.write "<a href='buildings.xml'>Buildings</a> (.xml) has been created <br>"
response.write "on " & now() & "<br>"
%>
</body>
</html>
 
You might need to alter the server.mappath to include any directories from your root folder? Thats the only thing I can see at this time.

Cheech

[Peace][Pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top