1. Create a XML class to get data from the database
Class clsXML
=============================================
Public Function getTOPN() As ADODB.Recordset
Dim strSql As String
On Error GoTo GErr
strSql = "select xmlserialize(content xmlelement(name " & """" & "Party" & """" & " ," & _
"xmlelement(name " & """" & "Party" & """" & ",integer(party))," & _
"xmlelement(name " & """" & "Party" & """" & ",party)," & _
"xmlelement(name " & """" & "W_cand" & """" & ",integer(w_cand))," & _
"xmlelement(name " & """" & "l_cand" & """" & ",integer(l_cand))" & _
")as varchar(500))as xmldata " & _
" from TOPN order by r "
Set getTOPNForXML = New ADODB.Recordset
getgetTOPNForXML.Open strSql, Cnn, adOpenStatic
Exit Function
GErr:
Err.Raise Err.Number, Err.Source, Err.Description
End Function
2.Create a form with a botton Generate XML call the XMLGenerator()
====================XML GENERATOR FUNCTION==================
Private Sub XMLGenerator()
Dim objRS As ADODB.Recordset
Dim objFS As New FileSystemObject
Dim objTS As TextStream
Dim objXML As New clsXML
Dim strPath As String
On Error GoTo XMLERR
lblCap.Caption = "Processing TopN Data"
strPath = App.Path & "\XML\" & Format(Date, "yyyymmdd") & Format(Time, "HHMMSS")
objFS.CreateFolder (strPath)
Set objTS = objFS.CreateTextFile(strPath & "\TopN.xml")
Set objRS = objXML.getCandForXML
objTS.WriteLine " objTS.WriteLine " pgXML.Min = 0
pgXML.Max = objRS.RecordCount
pgXML.Value = 0
Do While Not objRS.EOF
objTS.WriteLine objRS.Fields(0)
'pgXML.Value = pgXML.Value + 1
'lblPrg.Caption = Int((pgXML.Max / pgXML.Value) * 100) & "%Completed"
objRS.MoveNext
Loop
objTS.WriteLine ""
objTS.Close
Set objTS = Nothing
Set objRS = Nothing
MsgBox "Task Completed Successfully.... !!"
End Sub
Class clsXML
=============================================
Public Function getTOPN() As ADODB.Recordset
Dim strSql As String
On Error GoTo GErr
strSql = "select xmlserialize(content xmlelement(name " & """" & "Party" & """" & " ," & _
"xmlelement(name " & """" & "Party" & """" & ",integer(party))," & _
"xmlelement(name " & """" & "Party" & """" & ",party)," & _
"xmlelement(name " & """" & "W_cand" & """" & ",integer(w_cand))," & _
"xmlelement(name " & """" & "l_cand" & """" & ",integer(l_cand))" & _
")as varchar(500))as xmldata " & _
" from TOPN order by r "
Set getTOPNForXML = New ADODB.Recordset
getgetTOPNForXML.Open strSql, Cnn, adOpenStatic
Exit Function
GErr:
Err.Raise Err.Number, Err.Source, Err.Description
End Function
2.Create a form with a botton Generate XML call the XMLGenerator()
====================XML GENERATOR FUNCTION==================
Private Sub XMLGenerator()
Dim objRS As ADODB.Recordset
Dim objFS As New FileSystemObject
Dim objTS As TextStream
Dim objXML As New clsXML
Dim strPath As String
On Error GoTo XMLERR
lblCap.Caption = "Processing TopN Data"
strPath = App.Path & "\XML\" & Format(Date, "yyyymmdd") & Format(Time, "HHMMSS")
objFS.CreateFolder (strPath)
Set objTS = objFS.CreateTextFile(strPath & "\TopN.xml")
Set objRS = objXML.getCandForXML
objTS.WriteLine " objTS.WriteLine " pgXML.Min = 0
pgXML.Max = objRS.RecordCount
pgXML.Value = 0
Do While Not objRS.EOF
objTS.WriteLine objRS.Fields(0)
'pgXML.Value = pgXML.Value + 1
'lblPrg.Caption = Int((pgXML.Max / pgXML.Value) * 100) & "%Completed"
objRS.MoveNext
Loop
objTS.WriteLine ""
objTS.Close
Set objTS = Nothing
Set objRS = Nothing
MsgBox "Task Completed Successfully.... !!"
End Sub
Comments
Post a Comment
Give Your Comments