save.asp
<! - #includefile = "adovbs.inc" - >
<%
constantsFileIncludedAbove。
'ファイルが存在する場合は、削除します
dimobjfso
setobjfso = server.createObject( "Scripting.filesystemObject")
ifobjfso.fileexists(server.mappath( "db_xml.xml"))then
objfso.deletefileserver.mappath( "db_xml.xml")
endif
setobjfso =何もない
'変数宣言
dimcnnxml'adoconnection
dimrstxml'adorecordset
'データ接続オブジェクトを作成します
setcnnxml = server.createObject( "adodb.connection")
「これは、アクセスデータベースに接続する例です。
'cnnxml.open "provider = microsoft.jet.oledb.4.0; dataSource =" _
'&server.mappath( "db_scratch.mdb")& ";"
'以下は説明する例です。
cnnxml.open "provider = sqloledb; dataSource = 10.2.1.214;" _
& "initialCatalog = samples; userId = samples; password = password;" _
& "ConnectTimeout = 15; networkLibrary = dbmssocn;"
setrstxml = server.createObject( "adodb.recordset")
setrstxml = cnnxml.execute( "select*fromscratchOrderbyid;")
respons.write "<p> savingdataasxml ... </p>"&vbcrlf
'XML形式に保存します。
rstxml.saveserver.mappath( "db_xml.xml")、adpersistxml
'オブジェクトを閉じてリソースをリリースします
rstxml.close
setrstxml =何もない
cnnxml.close
setcnnxml = Nothing
respons.write "<p> xmlfilewriten ... </p>"&vbcrlf
Response.Write "<p>クリック<Ahref =" "db_xml.xml" "> here </a> toviewthefile。</p>"&vbcrlf
%>