2013-12-17 21 views
-2

我想從一個字符串構建一個XML文件,我得到一個預期的語句錯誤。我不知道什麼預期的語句VB錯誤輸出XML

是錯誤的,會導致此錯誤與條形圖的簡單循環。有任何想法嗎?

在此先感謝!佈雷特

<%@ Language=VBScript %> 

<% 
Dim oConn, rs 
Dim strConnQuery 
Set oConn = Server.CreateObject("ADODB.Connection") 
oConn.Mode = 1 
'Create the path to database 
oConn.open session("DSN") 
%> 

<% 
'This page generates the XML data for the Chart contained in 
'Default.asp. 

'Database Objects - Initialization 
Dim oRs, oRs2, strQuery 
'strXML will be used to store the entire XML document generated 
Dim strXML 

'Create the recordset to retrieve data 
Set oRs = Server.CreateObject("ADODB.Recordset") 


Function getTotals() 
    'Initialize database objects 
Dim oRs, strSQL 
'Variable to store XML Data 
Dim strXML 
'To store categories 
Dim strCat 
'To store amount Dataset & quantity dataset 

    Dim strAmtDS, strQtyDS 
strCat = "select * from fusion_category" 
strSQL = "select * from claim_table where reference_num =" & session("globalrefno") 

Set oRs = Server.CreateObject("ADODB.Recordset") 
oRs.Open strSQL, oConn 

'Initialize <categories> element 
strCat = "<categories>" 
'Response.Write(strCat) 
'Initialize datasets 
strIncDS = "<dataset seriesname='Incurred'>" 
strPdDS = "<dataset seriesName='Paid' parentYAxis='P'>" 

'Variable to store link 
Dim strLink 

'Iterate through each data row 
Do While not oRs.EOF 
strCat = strCat & "<category label='" & oRs("Category") & "'/>" 
strIncDS = strIncDS & "<set value='" & oRs("Incurred") & "'/>" 
strPdDS = strPdDS & "<set value='" & oRs("Paid") & "'/>" 
'oRs.EOF 

'Closing elements 
strCat = strCat & "</categories>" 
strIncDS = strIncDS & "</dataset>" 
strPdDS = strPdDS & "</dataset>" 

'Entire XML - concatenation 
strXML = strCat & strIncDS & strPdDS 

oRs.Close() 
Set oRs = nothing 

getTotals = strXML 

    End Function 

strXML = "<chart caption='Incurred vs Paid" & getTotals() & "' xAxisName='Year' palette='" & "'            numberPrefix='$' formatNumberScale='0'>" 
'Get the data 
strXML = strXML & "<set label='Incurred' value='" & getTotals() & "' />" 
strXML = strXML & "<set label='Paid' value='" & getTotals() & "' />" 
strXML = strXML & "</chart>" 

'Output it 
Response.ContentType = "text/xml" 
Response.Write(strXML) 

%> 
+0

不要通過字符串連接創建XML。使用[適當的方法](http://stackoverflow.com/a/284323/1630171)。 –

回答

1

Do While not oRs.EOF 

沒有關閉,所以

End Function 

是一個意外。