六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

ADO數據與XML數據間的轉換的類(ASP完成)

[摘要]當對現有數據庫的數據進行分析時,經常需要對某一部分的數據進行分析.此時,使用1.SQL查詢分析器? 但其往往不直觀,查找某個關鍵字又需要重新執行新的SQL.2.SQLXML模板? 但又不一定有權限建立新的虛擬目錄,且某些SQL語句SQLXML模板不支持數據拆離時也有相似問題。尤其當不同網絡,不同環...
當對現有數據庫的數據進行分析時,經常需要對某一部分的數據進行分析.此時,使用
1.SQL查詢分析器?
 但其往往不直觀,查找某個關鍵字又需要重新執行新的SQL.
2.SQLXML模板?
 但又不一定有權限建立新的虛擬目錄,且某些SQL語句SQLXML模板不支持
數據拆離時也有相似問題。
尤其當不同網絡,不同環境,需要重新導入數據,進行分析或拆離,困難尤為明顯。
能不能有一種方法,可以將數據脫離于數據庫進行分析,需要時再導入到數據庫中?
XML是個很好的選擇!
ADO本身支持數據到XML的轉換,只需要對其格式進行解析,成為自己的XML文件通用格式,就可以進行本地分析
而對通用XML格式進行數據庫映射,就可完成數據重新導入數據庫的工作.
下面是一個ADO數據(表的基本數據)與XML數據間的相互轉換的類(ASP實現),初步完成表數據的導入、導出。
通用表間關系映射(通過XSD描述),考慮之中,希望各位賜教指點,不勝感激.
一個調用類的例子:
example.asp
<!--#include file="transformData.asp"-->
<%
Dim aSQL(1,1)
Dim oXMLData
'====== 連接數據庫過程 ======
'獲得數據庫連接對象 oDbConn
'====== 連接數據庫過程 ======
aSQL(0,0) = "PubLable"
aSQL(0,1) = "Select * from PubLabel where cLabelName like '%abc%' Order by nLabelID"
aSQL(1,0) = "PubUser"
aSQL(1,1) = "Select * from PubUser where cUserName like '%abc%' Order by nUserID"
set oXMLData = New TransformData
Call Export()&nbsp;
'Call Import()&nbsp;
set oXMLData = nothing

'&nbsp;// 當對象屬性有默認值(default())時,可以不用在賦值
Sub Export()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp; // 導出數據
&nbsp;oXMLData.aSQlData&nbsp;&nbsp;= aSQL&nbsp;&nbsp;&nbsp;
&nbsp;' 必須&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2維SQL語句數組
&nbsp;
&nbsp;oXMLData.bIsSave&nbsp;&nbsp;= 1&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;' default(1)&nbsp;&nbsp;&nbsp;&nbsp;是否保存為XML文件
&nbsp;
&nbsp;oXMLData.bIsOutput&nbsp;&nbsp;= 1&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;' default(0)&nbsp;&nbsp;&nbsp;&nbsp;是否顯示XML數據
&nbsp;
&nbsp;oXMLData.sSaveFileName&nbsp;= "Data.xml"&nbsp;
&nbsp;' default(當前時間加隨機數)&nbsp;如果保存XML數據,XML文件名稱
&nbsp;
&nbsp;oXMLData.sSaveFilePath&nbsp;= ""&nbsp;&nbsp;&nbsp;
&nbsp;' default("")&nbsp;&nbsp;&nbsp;&nbsp;如果保存XML數據,XML文件路徑(相對路徑)
&nbsp;
&nbsp;oXMLData.sEncoding&nbsp;&nbsp;= "gb2312"&nbsp;&nbsp;
&nbsp;' default("gb2312")&nbsp;&nbsp;&nbsp;XML文件編碼類型
&nbsp;oXMLData.Export (oDbConn)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;' // 導出數據過程
&nbsp;IF (oXMLData.nErrCode<>0) Then&nbsp;&nbsp;' nErrCode(錯誤代碼)為0,運行成功
&nbsp;&nbsp;Response.Write oXMLData.GetErrExegesis(oXMLData.nErrCode)&nbsp;
&nbsp;&nbsp;'nErrCode(錯誤代碼),通過方法GetErrExegesis() 獲得注釋
&nbsp;End IF
End Sub
Sub Import()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp; // 導入數據
&nbsp;oXMLData.sXMLFile&nbsp;&nbsp;= "Data.xml"&nbsp;' 必須&nbsp;&nbsp;數據源XML文件(包含相對路徑)&nbsp;
&nbsp;oXMLData.sVacancyCols&nbsp;= "nLabelID"&nbsp;' 必須&nbsp;&nbsp;指定某些字段的值可以不導入(屏蔽字段)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' 格式&nbsp; &nbsp;"nID,dDate"&nbsp; (以‘,’分隔字段)
&nbsp;oXMLData.Import (oDbConn)
&nbsp;IF (oXMLData.nErrCode=0) Then
&nbsp;&nbsp;Response.Write "數據導入成功!"
&nbsp;Else
&nbsp;&nbsp;Response.Write oXMLData.GetErrExegesis(oXMLData.nErrCode)
&nbsp;End IF
&nbsp;
End Sub
%>
&nbsp;
類的代碼:
TransformData.asp
<%
Class TransformData
'*****************************************************
'&nbsp;Copyright (c) 2003
'&nbsp;創 建 人&nbsp;:&nbsp;moonpiazza
'&nbsp;日&nbsp;&nbsp;&nbsp; 期&nbsp;:&nbsp;2003.5.21
'&nbsp;描&nbsp;&nbsp;&nbsp; 述&nbsp;:&nbsp;ADO數據與XML數據間的轉換(ASP實現)
'&nbsp;版&nbsp;&nbsp;&nbsp; 本&nbsp;:&nbsp;1.0
'&nbsp;功&nbsp;&nbsp;&nbsp; 能&nbsp;:&nbsp;&nbsp; ADO數據(表的基本數據)與XML數據間的相互轉換
'&nbsp;待 改 進&nbsp;:&nbsp;表間數據的關聯性(通用),數據量大時速度問題
'
'&nbsp;版&nbsp;權&nbsp;:&nbsp;歡迎改進,翻版不究&nbsp;&nbsp;:_)
'
'*****************************************************

'*****************************************************
'&nbsp;公共方法:&nbsp;Export, Import, GetErrExegesis
'*****************************************************
'============================= 公共變量&nbsp; End =============================
Private m_oXMLDOM
Private m_oXSLDOM
'============================= 公共變量 Begin =============================
&nbsp;
'============================= 錯誤代碼定義 Begin =============================
Private m_nErrCode_NotArray&nbsp;
Private m_nErrCode_XMLDOM&nbsp;
Private m_nErrCode_ReadData&nbsp;
Private m_nErrCode_WriteData
Private m_nErrCode_Save&nbsp;&nbsp;
Private m_nErrCode_EnsFile&nbsp;
Private m_nErrCode_ErrFile&nbsp;
'============================= 錯誤代碼定義&nbsp; End =============================
&nbsp;
'============================= 屬性定義 Begin =============================
Private m_aSQlData&nbsp;&nbsp;
Private m_bIsSave
Private m_bIsOutput
Private m_sSaveFileName
Private m_sSaveFilePath
Private m_sXMLFile
Private m_sVacancyCols
Private m_nErrCode
Private m_sEncoding
Private m_sImportSQL
'*****************************************************
'&nbsp;屬性:&nbsp;aSQlData
'&nbsp;狀態:&nbsp;可寫
'&nbsp;類型:&nbsp;2維數組&nbsp;
'&nbsp;描述:&nbsp;SQL語句數組,1維是表名稱,2維是相應SQL語句
'*****************************************************
Public Property Let aSQlData(ByRef p_aSQlData)
&nbsp;m_aSQlData&nbsp;= p_aSQlData
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;bIsSave
'&nbsp;狀態:&nbsp;可寫
'&nbsp;類型:&nbsp;數字(0,1)&nbsp;default(1)
'&nbsp;描述:&nbsp;導出數據時,是否保存為XML文件&nbsp;
'*****************************************************
Public Property Let bIsSave(ByRef p_bIsSave)
&nbsp;m_bIsSave&nbsp;= Cint(p_bIsSave)
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;bIsOutput
'&nbsp;狀態:&nbsp;可寫
'&nbsp;類型:&nbsp;數字(0,1)&nbsp;default(0)
'&nbsp;描述:&nbsp;導出數據時,是否顯示XML數據
'*****************************************************
Public Property Let bIsOutput(ByRef p_bIsOutput)
&nbsp;m_bIsOutput&nbsp;= Cint(p_bIsOutput)
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;sSaveFileName
'&nbsp;狀態:&nbsp;可寫,可讀
'&nbsp;類型:&nbsp;字符串&nbsp;default(GetRndFileName())
'&nbsp;描述:&nbsp;導出數據時,如果保存XML數據,XML文件名稱
'*****************************************************
Public Property Let sSaveFileName(ByRef p_sSaveFileName)
&nbsp;m_sSaveFileName&nbsp;= p_sSaveFileName
End Property
Public Property Get sSaveFileName()&nbsp;
&nbsp;sSaveFileName&nbsp;= m_sSaveFileName
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;sSaveFilePath
'&nbsp;狀態:&nbsp;可寫,可讀
'&nbsp;類型:&nbsp;字符串&nbsp;default("")
'&nbsp;描述:&nbsp;導出數據時,如果保存XML數據,XML文件路徑(相對路徑)
'*****************************************************
Public Property Let sSaveFilePath(ByRef p_sSaveFilePath)
&nbsp;m_sSaveFilePath&nbsp;= p_sSaveFilePath
End Property
Public Property Get sSaveFilePath()&nbsp;
&nbsp;sSaveFilePath&nbsp;= m_sSaveFilePath
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;sXMLFile
'&nbsp;狀態:&nbsp;可寫
'&nbsp;類型:&nbsp;字符串&nbsp;
'&nbsp;描述:&nbsp;導入數據時,數據源XML文件(包含相對路徑)&nbsp;
'*****************************************************
Public Property Let sXMLFile(ByRef p_sXMLFile)
&nbsp;m_sXMLFile&nbsp;= p_sXMLFile
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;sVacancyCols
'&nbsp;狀態:&nbsp;可寫
'&nbsp;類型:&nbsp;字符串&nbsp;default("")
'&nbsp;&nbsp;&nbsp;格式&nbsp; &nbsp;"nID,dDate"&nbsp; (以‘,’分隔字段)
'&nbsp;描述:&nbsp;導入數據時,指定某些字段的值可以不導入(屏蔽字段)
'*****************************************************
Public Property Let sVacancyCols(ByRef p_sVacancyCols)
&nbsp;m_sVacancyCols&nbsp;= "," & p_sVacancyCols & ","
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;nErrCode
'&nbsp;狀態:&nbsp;可讀
'&nbsp;類型:&nbsp;數字 &nbsp;default(0)
'&nbsp;描述:&nbsp;錯誤代碼,可通過方法GetErrExegesis(ByRef p_nErrCode) 獲得注釋
'*****************************************************
Public Property Get nErrCode()&nbsp;
&nbsp;nErrCode&nbsp;= m_nErrCode
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;sEncoding
'&nbsp;狀態:&nbsp;可寫
'&nbsp;類型:&nbsp;字符串&nbsp;default("gb2312")
'&nbsp;描述:&nbsp;XML文件編碼類型
'*****************************************************
Public Property Let sEncoding(ByRef p_sEncoding)
&nbsp;m_sEncoding&nbsp;= p_sEncoding
End Property

'*****************************************************
'&nbsp;屬性:&nbsp;sImportSQL
'&nbsp;狀態:&nbsp;可讀
'&nbsp;類型:&nbsp;字符串&nbsp;default("gb2312")
'&nbsp;描述:&nbsp;導入數據時,生成的SQL語句
'*****************************************************
Public Property Get sImportSQL()&nbsp;
&nbsp;sImportSQL&nbsp;= m_sImportSQL
End Property
'============================= 屬性定義 End =============================
&nbsp;
'*****************************************************
'&nbsp;初始化類
'*****************************************************
Private Sub Class_Initialize()
&nbsp;Server.ScriptTimeout = 1000
&nbsp;m_nErrCode_NotErr&nbsp;= 0
&nbsp;m_nErrCode_NotArray&nbsp;= 1
&nbsp;m_nErrCode_XMLDOM&nbsp;= 2
&nbsp;m_nErrCode_ReadData&nbsp;= 3
&nbsp;m_nErrCode_WriteData= 4
&nbsp;m_nErrCode_Save&nbsp;&nbsp;= 5
&nbsp;m_nErrCode_EnsFile&nbsp;= 6
&nbsp;m_nErrCode_ErrFile&nbsp;= 7

&nbsp;m_bIsSave&nbsp;&nbsp;&nbsp;= 1
&nbsp;m_bIsOutput&nbsp;&nbsp;&nbsp;= 0
&nbsp;m_sSaveFilePath&nbsp;&nbsp;= ""
&nbsp;m_sSaveFileName&nbsp;&nbsp;= ""
&nbsp;m_sXMLFile&nbsp;&nbsp;&nbsp;= ""
&nbsp;m_sVacancyCols&nbsp;&nbsp;= ""
&nbsp;m_nErrCode&nbsp;&nbsp;&nbsp;= m_nErrCode_NotErr
&nbsp;m_sEncoding&nbsp;&nbsp;&nbsp;= "gb2312"
End Sub

'*****************************************************
'&nbsp;注銷類
'*****************************************************
Private Sub Class_Terminate()
&nbsp;&nbsp;Set m_oXMLDOM&nbsp;= Nothing
&nbsp; Set m_oXSLDOM&nbsp;= Nothing&nbsp;
End Sub

'============================= 數據導出 Begin =============================
'*****************************************************
'&nbsp;過程:&nbsp;Export(ByRef p_oDbConn)
'&nbsp;描述:&nbsp;導出數據
'&nbsp;參數:&nbsp;
'&nbsp;&nbsp;&nbsp;p_oDbConn:&nbsp;數據庫連接對象
'
'*****************************************************
Public Sub Export(ByRef p_oDbConn)
&nbsp;Dim nI, nMaxI
&nbsp;Dim sTableName, sSQL
&nbsp;Dim sDataXML, sXSLStr
&nbsp;Dim sXMLStr
&nbsp;
&nbsp;If (Not IsArray(m_aSQlData)) Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_NotArray
&nbsp;&nbsp;Exit Sub
&nbsp;End If
&nbsp;ON ERROR RESUME NEXT
&nbsp;Set m_oXSLDOM&nbsp;= Server.CreateObject("Microsoft.XMLDOM")
&nbsp;Set m_oXMLDOM&nbsp;= Server.CreateObject("Microsoft.XMLDOM")
&nbsp;
&nbsp;If Err.Number <>0 Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_XMLDOM
&nbsp;&nbsp;Exit Sub
&nbsp;End If
&nbsp;
&nbsp;sXSLStr&nbsp;&nbsp;&nbsp;= GetXSL()&nbsp;&nbsp;
&nbsp;m_oXMLDOM.async&nbsp;= false&nbsp;
&nbsp;m_oXSLDOM.async&nbsp;= false
&nbsp;m_oXSLDOM.loadxml(sXSLStr)
&nbsp;
&nbsp;sDataXML&nbsp;= "<?xml version='1.0' encoding='" & m_sEncoding & "'?>"
&nbsp;sDataXML&nbsp;= sDataXML & "<DataBase>"
&nbsp;nMaxI&nbsp;= Ubound(m_aSQlData, 1)
&nbsp;For nI=0 To&nbsp;nMaxI
&nbsp;&nbsp;sTableName&nbsp;= m_aSQlData(nI, 0)
&nbsp;&nbsp;If (Len(sTableName) > 0) Then
&nbsp;&nbsp;&nbsp;sSQL&nbsp;&nbsp;= m_aSQlData(nI, 1)
&nbsp;&nbsp;&nbsp;sXMLStr&nbsp;&nbsp;= GetDataXML(sTableName, sSQL, p_oDbConn)
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;IF (m_nErrCode > m_nErrCode_NotErr) Then
&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub
&nbsp;&nbsp;&nbsp;End IF
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;sDataXML&nbsp;= sDataXML & sXMLStr
&nbsp;&nbsp;End If&nbsp;&nbsp;
&nbsp;
&nbsp;Next
&nbsp;sDataXML&nbsp;= sDataXML & "</DataBase>"
&nbsp;
&nbsp;IF (m_bIsOutput) Then
&nbsp;&nbsp;Call ResponseXML(sDataXML)
&nbsp;End IF
&nbsp;
&nbsp;IF (m_bIsSave) Then
&nbsp;&nbsp;Call SaveDataXML(sDataXML)
&nbsp;End IF&nbsp;
&nbsp;
End Sub

'*****************************************************
'&nbsp;函數:&nbsp;GetRndFileName()
'&nbsp;描述:&nbsp;獲得隨機名稱,由當前時間和7位隨機數字構成
'*****************************************************
Private Function GetRndFileName()
&nbsp;Dim nMax, nMin
&nbsp;Dim sRnd, sDate
&nbsp;Randomize
&nbsp;nMin&nbsp;= 1000000
&nbsp;nMax&nbsp;= 9999999
&nbsp;sRnd&nbsp;= Int( ( (nMax - nMin + 1) * Rnd ) + nMin)
&nbsp;sDate&nbsp;= Replace( Replace( Replace( now(), "-", "") , ":", ""), " ", "")
&nbsp;GetRndFileName&nbsp;= "_" & sDate & sRnd & ".xml"
&nbsp;
End Function

'*****************************************************
'&nbsp;函數:&nbsp;GetXSL()
'&nbsp;描述:&nbsp;獲得XSL文件字符串
'*****************************************************
Private Function GetXSL()
&nbsp;Dim sXSLStr
&nbsp;sXSLStr&nbsp;= ""
&nbsp;sXSLStr&nbsp;= sXSLStr & "<?xml version='1.0' encoding='" & m_sEncoding & "'?>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:output omit-xml-declaration='yes'/>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:template match='/'>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:for-each select='/xml/rs:data/z:row'>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:element name='Row'>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:for-each select='@*'>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:attribute name='{name()}'>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "<xsl:value-of select='.'/>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "</xsl:attribute>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "</xsl:for-each>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "</xsl:element>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "</xsl:for-each>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "</xsl:template>"
&nbsp;sXSLStr&nbsp;= sXSLStr & "</xsl:stylesheet>"
&nbsp;GetXSL&nbsp;= sXSLStr&nbsp;
&nbsp;
End Function

'*****************************************************
'&nbsp;函數:&nbsp;GetDataXML(ByRef p_sTableName, ByRef p_sSQL, ByRef p_oDbConn)
'&nbsp;描述:&nbsp;執行單條SQL,獲得數據轉換后的XML
'&nbsp;參數:&nbsp;
'&nbsp;&nbsp;&nbsp;1.p_sTableName&nbsp;:&nbsp;表的名稱
'&nbsp;&nbsp;&nbsp;2.p_sSQL&nbsp;&nbsp;:&nbsp;讀取數據的SQl語句
'&nbsp;&nbsp;&nbsp;3.p_oDbConn&nbsp;&nbsp;:&nbsp;數據庫連接對象
'
'*****************************************************
Private Function GetDataXML(ByRef p_sTableName, ByRef p_sSQL, ByRef p_oDbConn)
&nbsp;Dim oRecordset
&nbsp;Dim sXMLStr, sCleanXML
&nbsp;Dim nEnsData
&nbsp;ON ERROR RESUME NEXT
&nbsp;nEnsData&nbsp;&nbsp;= 0
&nbsp;Set oRecordset&nbsp;= p_oDbConn.Execute(p_sSQL)
&nbsp;If Err.Number <>0 Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_ReadData
&nbsp;&nbsp;Exit Function
&nbsp;End If
&nbsp;IF (Not oRecordset.eof) Then
&nbsp;&nbsp;nEnsData&nbsp;= 1
&nbsp;End IF
&nbsp;
&nbsp;IF (nEnsData = 1) Then
&nbsp;&nbsp;oRecordset.save m_oXMLDOM, 1
&nbsp;&nbsp;
&nbsp;&nbsp;oRecordset.close
&nbsp;&nbsp;Set oRecordset&nbsp;= Nothing
&nbsp;&nbsp;sCleanXML&nbsp;= m_oXMLDOM.transformNode(m_oXSLDOM)
&nbsp;&nbsp;sXMLStr&nbsp;&nbsp;= "<" & p_sTableName & ">"
&nbsp;&nbsp;sXMLStr&nbsp;&nbsp;= sXMLStr & sCleanXML
&nbsp;&nbsp;sXMLStr&nbsp;&nbsp;= sXMLStr & "</" & p_sTableName & ">"
&nbsp;Else
&nbsp;&nbsp;sXMLStr&nbsp;&nbsp;= "<" & p_sTableName & "/>"
&nbsp;End IF
&nbsp;

&nbsp;GetDataXML&nbsp;= sXMLStr
End Function

'*****************************************************
'&nbsp;過程:&nbsp;SaveDataXML(ByRef p_sXMLStr)
'&nbsp;描述:&nbsp;保存XML格式的字符串到文件
'&nbsp;參數:&nbsp;
'&nbsp;&nbsp;&nbsp;p_sXMLStr&nbsp;:&nbsp;XML格式的字符串
'*****************************************************
Private Sub SaveDataXML(ByRef p_sXMLStr)
&nbsp;Dim sFileInfo&nbsp;
&nbsp;If (Len(m_sSaveFileName) = 0) Then
&nbsp;&nbsp;m_sSaveFileName&nbsp;= GetRndFileName()
&nbsp;End If&nbsp;
&nbsp;
&nbsp;If (Len(m_sSaveFilePath) = 0) Then
&nbsp;&nbsp;sFileInfo&nbsp;= m_sSaveFileName
&nbsp;Else
&nbsp;&nbsp;IF (Right(m_sSaveFilePath,1) = "/")Then
&nbsp;&nbsp;&nbsp;sFileInfo&nbsp;= m_sSaveFilePath & m_sSaveFileName
&nbsp;&nbsp;Else&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;sFileInfo&nbsp;= m_sSaveFilePath & "/" & m_sSaveFileName
&nbsp;&nbsp;End IF&nbsp;&nbsp;
&nbsp;End If&nbsp;
&nbsp;m_oXMLDOM.loadxml(p_sXMLStr)
&nbsp;ON ERROR RESUME NEXT
&nbsp;m_oXMLDOM.save ( Server.MapPath(sFileInfo) )
&nbsp;If Err.Number <>0 Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_Save
&nbsp;&nbsp;Exit Sub
&nbsp;End If
End Sub
'*****************************************************
'&nbsp;過程:&nbsp;ResponseXML(ByRef p_sXMLStr)
'&nbsp;描述:&nbsp;輸出XML格式的字符串到瀏覽器
'&nbsp;參數:&nbsp;
'&nbsp;&nbsp;&nbsp;p_sXMLStr&nbsp;:&nbsp;XML格式的字符串
'*****************************************************
Private Sub ResponseXML(ByRef p_sXMLStr)
&nbsp;Response.CharSet&nbsp;&nbsp;= m_sEncoding
&nbsp;Response.ContentType&nbsp;= "text/xml"
&nbsp;Response.write p_sXMLStr
End Sub

'============================= 數據導出 End =============================
&nbsp;
'============================= 數據導入 Begin =============================
'*****************************************************
'&nbsp;過程:&nbsp;Import(ByRef p_oDbConn)
'&nbsp;描述:&nbsp;導入數據
'&nbsp;參數:&nbsp;
'&nbsp;&nbsp;&nbsp;p_oDbConn:&nbsp;數據庫連接對象
'
'*****************************************************
Public Sub Import(ByRef p_oDbConn)
&nbsp;Dim oRootNode
&nbsp;If (Len(m_sXMLFile) < 1) Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_EnsFile
&nbsp;&nbsp;Exit Sub
&nbsp;End If
&nbsp;ON ERROR RESUME NEXT
&nbsp;Set m_oXMLDOM&nbsp;= Server.CreateObject("Microsoft.XMLDOM")
&nbsp;
&nbsp;If Err.Number <>0 Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_XMLDOM
&nbsp;&nbsp;Exit Sub
&nbsp;End If
&nbsp;
&nbsp;m_oXMLDOM.async&nbsp;= false&nbsp;
&nbsp;m_oXMLDOM.load( Server.MapPath(m_sXMLFile) )
&nbsp;If Err.Number <>0 Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_EnsFile
&nbsp;&nbsp;Exit Sub
&nbsp;End If
&nbsp;If (Len(m_oXMLDOM.xml) < 1) Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_ErrFile
&nbsp;&nbsp;Exit Sub
&nbsp;End If
&nbsp;Set&nbsp;oRootNode&nbsp;= m_oXMLDOM.documentElement
&nbsp;Set m_oXMLDOM&nbsp;&nbsp;= Nothing
&nbsp;
&nbsp;m_sImportSQL&nbsp;= GetImportSQL(oRootNode)
&nbsp;Set oRootNode&nbsp;= Nothing
&nbsp;Call p_oDbConn.Execute(m_sImportSQL)
&nbsp;If Err.Number <>0 Then
&nbsp;&nbsp;m_nErrCode&nbsp;= m_nErrCode_WriteData
&nbsp;&nbsp;Exit Sub
&nbsp;End If
&nbsp;
End Sub

'*****************************************************
'&nbsp;函數:&nbsp;GetImportSQL(ByRef p_oDataBase)
'&nbsp;描述:&nbsp;獲得將XML數據轉換為SQL后的字符串
'&nbsp;參數:&nbsp;
'&nbsp;&nbsp;&nbsp;p_oDataBase&nbsp;&nbsp;:&nbsp;XML文件的根節點
'
'*****************************************************
Private Function GetImportSQL(ByRef p_oDataBase)
&nbsp;Dim oTable, oRow, oDatas, oData
&nbsp;Dim sColNames, sColValues
&nbsp;Dim sColName
&nbsp;Dim sSQL, sTransactionSQL

&nbsp;sSQL&nbsp;= ""
&nbsp;For Each oTable In p_oDataBase.childNodes&nbsp;
&nbsp;
&nbsp;&nbsp;For Each oRow In oTable.childNodes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Set oDatas&nbsp;= oRow.selectNodes("@*")
&nbsp;&nbsp;&nbsp;&nbsp;sColNames&nbsp;= ""
&nbsp;&nbsp;&nbsp;&nbsp;sColValues&nbsp;= ""
&nbsp;&nbsp;&nbsp;&nbsp;For Each oData In oDatas
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sColName&nbsp;= oData.nodeName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If ( Instr( Lcase(Cstr(m_sVacancyCols)), Lcase(Cstr("," & sColName & ",")) ) < 1) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sColNames&nbsp;= sColNames & sColName & ", "&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sColValues&nbsp;= sColValues & "'" & oData.nodeValue & "', "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Next
&nbsp;&nbsp;&nbsp;&nbsp;sColNames&nbsp;= "(" & Left(sColNames,Len(sColNames)-2) & ") "
&nbsp;&nbsp;&nbsp;&nbsp;sColValues&nbsp;= "(" & Left(sColValues,Len(sColValues)-2) & ") "
&nbsp;&nbsp;&nbsp;&nbsp;sSQL&nbsp;= sSQL & " Insert Into " & oTable.nodeName
&nbsp;&nbsp;&nbsp;&nbsp;sSQL&nbsp;= sSQL & " " & sColNames & " Values " & sColValues & " ;&nbsp; "
&nbsp;&nbsp;Next
&nbsp;Next
&nbsp;Set oData&nbsp;= Nothing
&nbsp;Set oDatas&nbsp;= Nothing
&nbsp;Set oRow&nbsp;= Nothing
&nbsp;Set oTable&nbsp;= Nothing
&nbsp;sTransactionSQL = "Set Xact_Abort On; "
&nbsp;sTransactionSQL = sTransactionSQL & " Begin Transaction; "
&nbsp;sTransactionSQL = sTransactionSQL & sSQL
&nbsp;sTransactionSQL = sTransactionSQL & " Commit Transaction; "
&nbsp;sTransactionSQL = sTransactionSQL & " Set Xact_Abort Off; "
&nbsp;GetImportSQL&nbsp;= sTransactionSQL
End Function
'============================= 數據導入 End =============================

'*****************************************************
'&nbsp;函數:&nbsp;GetErrExegesis(ByRef p_nErrCode)
'&nbsp;描述:&nbsp;獲得錯誤代碼的注釋
'&nbsp;參數:&nbsp;
'&nbsp;&nbsp;&nbsp;p_oDataBase&nbsp;&nbsp;:&nbsp;XML文件的根節點
'
'*****************************************************
Public Function GetErrExegesis(ByRef p_nErrCode)
&nbsp;Dim sExegesis
&nbsp;Dim nErrCode
&nbsp;nErrCode&nbsp;= Cint(p_nErrCode)
&nbsp;
&nbsp;Select Case (nErrCode)
&nbsp;&nbsp;Case m_nErrCode_NotErr
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "運行成功!"
&nbsp;&nbsp;Case m_nErrCode_NotArray
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "屬性: SQL語句數組 不正確!"
&nbsp;&nbsp;Case m_nErrCode_XMLDOM
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "不能創建XML文檔,服務器必須支持MSXML!"
&nbsp;&nbsp;Case m_nErrCode_ReadData
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "讀取數據庫數據發生錯誤! " & "<BR>"
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & " 請檢查 " & " "
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "1.數據庫是否已連接 " & " "
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "2.語句是否正確 "
&nbsp;&nbsp;Case m_nErrCode_WriteData
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "寫入數據庫數據發生錯誤! " & "<BR>"
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & " 請檢查 " & " "
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "1.數據庫是否已連接 " & " "
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "2.SQL語句是否正確 " & "<BR>"
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "SQL語句 " & "<BR><BR>"
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "" & m_sImportSQL
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;Case m_nErrCode_Save
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "不能保存XML文檔,請檢查是否對該目錄或文件有' 寫入權限 ' !"
&nbsp;&nbsp;Case m_nErrCode_EnsFile
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "不能讀取XM數據,XML文件不存在 ' !"
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "文件:" & m_sXMLFile
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;Case m_nErrCode_ErrFile
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "不能讀取XM數據,XML文件格式錯誤 ' !"
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= sXSLStr & "文件:" & m_sXMLFile
&nbsp;
&nbsp;&nbsp;Case Else
&nbsp;&nbsp;&nbsp;sXSLStr&nbsp;= "未知錯誤 !"
&nbsp;End Select
&nbsp;
&nbsp;GetErrExegesis&nbsp;= "<BR>" & sXSLStr & "<BR>"
&nbsp;
End Function
End Class
%>


主站蜘蛛池模板: 色综合天天综合中文网 | 四虎影视在永久在线观看 2019 | 日产精品一卡2卡三卡4乱码久久 | 欧美亚洲日本视频 | 在线精品91青草国产在线观看 | 小说区 亚洲 自拍 另类 | 欧美一线视频 | 亚洲第成色999久久网站 | 一本久道久久综合多人 | 四虎影视在线影院4hutv | 小草青青免费影视观看 | 亚洲精品欧美在线 | 手机看片日韩高清国产欧美 | 四虎免费在线观看 | 特黄特黄aaaa级毛片免费看 | 欧美中文字幕在线 | 日本网络视频www色高清免费 | 人人艹人人射 | 午夜成人在线视频 | 日日干狠狠干 | 日日摸夜夜添夜夜添特色大片 | 小草社区在线观看播放 | 日韩一页 | 日本激情视频 | 亚洲乱强伦 | 亚洲视频一二区 | 青青青青手机在线视频观看国产 | 色噜噜狠狠色综合欧洲 | 日本最新在线 | 日本五级床片全都免费播放 | 香蕉国产成版人视频在线观看 | 啪啪网站色大全免费 | 中文字幕专区高清在线观看 | 天天干天天操天天玩 | 情不自禁完整版在线观看免费 | 日韩精品一区二区三区大桥未久 | 小情侣旅馆内无套啪啪 | 午夜性色视频 | 青娱极品盛宴国产一区 | 日韩在线视频第一页 | 亚洲男人的天堂网 |