|
CodeAve.com - ASP - Read/Write | ||||
|
|
|||||
| Access To HTML | |||||
![]() After reading the contents of the db instead of writing output to the browser it is written to the server. Each observation (state) will have its own dynamically created page with its corresponding info displayed as well. A table of contents page is also created (in the browser) for easy navigation around all the state pages. The current time (server time) is also added to show that all the .htm pages are created on the fly. |
|||||
<% accessdb="state_info" cn="DRIVER={Microsoft Access Driver (*.mdb)};" cn=cn & "DBQ=" & server.mappath(accessdb) Set rs = Server.CreateObject("ADODB.Recordset") sql = "select * from states " rs.Open sql, cn rs.MoveFirst do while not rs.eof ' Creates a text file on the server with the state abbreviation ' as the name for the ouput document file_being_created= rs("state") & ".htm" set fso = createobject("scripting.filesystemobject") Set act = fso.CreateTextFile(server.mappath(file_being_created), true) ' Writes the db output to a .htm file in the same directory act.WriteLine("<title>CodeAve.com(" & rs("statename") & " State Info)</title>") act.WriteLine("<body bgcolor='#FFFFFF'> " ) act.WriteLine("State: " & rs("statename") & "<br>" ) act.WriteLine("Abbreviaton: " & rs("state") & "<br>" ) act.WriteLine("Capital: " & rs("capital") & "<br>") act.WriteLine("Entered the Union in "& rs("year") & "<br>") act.WriteLine("Number in order of entrance into the Union "& rs("order") & "<br>") act.WriteLine("Page created on: " & now ()) act.close ' Writes the links to the newly created pages in the browser response.write "<a href='" & rs("state") & ".htm'>" & rs("statename") & "</a> " & now() & "<br>" rs.movenext loop %>
|
|||||
|
|
|||||