asp下將數(shù)據(jù)庫中的信息存儲至XML文件中
更新時間:2007年04月06日 00:00:00 作者:
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
'創(chuàng)建數(shù)據(jù)連接對象
Set cnnXML = Server.CreateObject("ADODB.Connection")
' 這是連接access數(shù)據(jù)庫的例子:
'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
' 關(guān)閉對象、釋放資源
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
%>
<!-- #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
'創(chuàng)建數(shù)據(jù)連接對象
Set cnnXML = Server.CreateObject("ADODB.Connection")
' 這是連接access數(shù)據(jù)庫的例子:
'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
' 關(guān)閉對象、釋放資源
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
%>
您可能感興趣的文章:
- asp access數(shù)據(jù)庫并生成XML文件范例
- Javascript+XMLHttpRequest+asp.net無刷新讀取數(shù)據(jù)庫數(shù)據(jù)
- ASP XML操作類代碼
- ASP讀取XML實例 優(yōu)酷專輯采集程序 雷鋒版
- ASP XMLDom在服務(wù)器端操作XML文件的主要方法和實現(xiàn)
- Asp操作Xml的精煉類,含示例代碼
- ASP.NET+XML打造網(wǎng)絡(luò)硬盤原理分析
- asp xmlhttp下載一句話
- asp.net TreeView與XML三步生成列表樹
- Asp 解析 XML并分頁顯示源碼
- ASP.NET中XML轉(zhuǎn)JSON的方法實例
- ASP.net處理XML數(shù)據(jù)實例淺析
- ASP.NET XmlDocument類詳解
- asp.net中XML如何做增刪改查操作
- asp控制xml數(shù)據(jù)庫的經(jīng)典代碼
相關(guān)文章
談動態(tài)多行多列,循環(huán)行和列,輸出M行N列的ASP代碼
2008-03-03對象不支持此屬性或方法: Session.CodePage = 936 解決方法
這篇文章主要介紹了對象不支持此屬性或方法: Session.CodePage = 936 解決方法,需要的朋友可以參考下2015-07-07