DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> XML學習教程 >> XML詳解 >> ASP將數據庫中的信息存儲至XML文件中
ASP將數據庫中的信息存儲至XML文件中
編輯:XML詳解     
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
  %>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved