将ado方便的转化为XML文件
2002-10-16 10:23:32 来源:WEB开发网核心提示:<!-- #include file="adovbs.inc" --><%' 删除已经存在的文件Dim objfsoSet objFSO = Server.CreateObject("Scripting.FileSystemObject")If objF
<!-- #include file="adovbs.inc" -->
<%
' 删除已经存在的文件
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 连接
Dim rstXML ' ADO 记录集
Set cnnXML = Server.CreateObject("ADODB.Connection")
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
%>
<%
' 删除已经存在的文件
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 连接
Dim rstXML ' ADO 记录集
Set cnnXML = Server.CreateObject("ADODB.Connection")
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
%>
- ››Adobe推出用于iOS设备创建PDF文件的应用
- ››Adobe发布Acrobat X 不支持苹果iOS系统
- ››Adobe公司展示plenoptic lenses技术
- ››Adobe:移动版Flash实测性能高于HTML5视频
- ››Adobe更新Web版Photoshop 无需注册即可使用
- ››Adobe Flash 10.1被曝支持Android效果不佳
- ››Adobe Flash 10.1 for Android 版本被曝工作状况不...
- ››Adobe CEO:不担心iPhone和iPad封Flash技术
- ››Adobe为iPad、Android平台发布免费Photoshop
- ››Adobe发布Android版Flash 10.1 Beta 3
- ››ADO VC++ Extensions入门
- ››Adobe反戈一击抛弃iPhone 苹果真的赢了?
更多精彩
赞助商链接