Store the information in the database to an XML file under asp

Source: Internet
Author: User

Save. asp
<! -- # Include file = "adovbs. inc" -->
<%
'Constants file supported ded above.
'Delete if the file exists.
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
'Variable Declaration
Dim cnnXML 'ado connection
Dim rstXML 'ado recordset
'Create a data connection object
Set cnnXML = Server. CreateObject ("ADODB. Connection ")
'Here is an example of connecting to the access database:
'Cnnxml. Open "Provider = Microsoft. Jet. OLEDB.4.0; Data Source = "_
'& Server. MapPath ("db_scratch.mdb ")&";"
'Here is an example of 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
'Save to xml format.
RstXML. Save Server. MapPath ("db_xml.xml"), adPersistXML
'Close objects and release resources
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
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.