save.asp
<!-- #include file="adovbs.inc" -->
<%
' constants file included above.
' 如果文件存在则删除
dim objfso
set objfso = server.createobject("scripting.filesystemobject")
if objfso.fileexists(server.mappath("db_xml.xml")) then
objfso.deletefile server.mappath("db_xml.xml")
end if
set objfso = nothing
'变量声明
dim cnnxml ' ado connection
dim rstxml ' ado recordset
'创建数据连接对象
set cnnxml = server.createobject("adodb.connection")
' 这是连接access数据库的例子:
'cnnxml.open "provider=microsoft.jet.oledb.4.0;data source=" _
' & server.mappath("db_scratch.mdb") & ";"
' 下面以sqlserver为例子讲解:
cnnxml.open "provider=sqloledb;data source=10.2.1.214;" _
& "initial catalog=samples;user id=samples;password=password;" _
& "connect timeout=15.network library=dbmssocn;"
set rstxml = server.createobject("adodb.recordset")
set rstxml = cnnxml.execute("select * from scratch order by id;")
response.write "<p>saving data as xml...</p>" & vbcrlf
' 保存至xml格式.
rstxml.save server.mappath("db_xml.xml"), adpersistxml
' 关闭对象、释放资源
rstxml.close
set rstxml = nothing
cnnxml.close
set cnnxml = nothing
response.write "<p>xml file written...</p>" & vbcrlf
response.write "<p>click <a href=""db_xml.xml"">here</a> to view the file.</p>" & vbcrlf
%>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器