Graph 如何解决VBScript(经典ASP)中的运行时错误('800a01a8')?
我有以下经典的asp代码:Graph 如何解决VBScript(经典ASP)中的运行时错误('800a01a8')?,graph,asp-classic,vbscript,Graph,Asp Classic,Vbscript,我有以下经典的asp代码: <BODY> <% 'In this example, we show how to connect FusionCharts to a database. 'For the sake of ease, we've used an Access database which is present in '../DB/FactoryDB.mdb. It just contains two tables, which are
<BODY>
<%
'In this example, we show how to connect FusionCharts to a database.
'For the sake of ease, we've used an Access database which is present in
'../DB/FactoryDB.mdb. It just contains two tables, which are linked to each
'other.
'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")
'Generate the chart element
strXML = "<graph caption='Factory Output report' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"
'Iterate through each factory
strQuery = "select * from deal_price"
Set oRs = oConnection.Execute(strQuery)
While Not oRs.Eof
'Now create second recordset to get details for this factory
Set oRs2 = Server.CreateObject("ADODB.Recordset")
strQuery = "select sum(price) as TotOutput from deal_price where deal_id=" & ors("deal_id")
Set oRs2 = oConnection.Execute(strQuery)
'Generate <set name='..' value='..'/>
strXML = strXML & "<set name='" & ors("name") & "' value='" & ors2("TotOutput") & "' />"
'Close recordset
Set oRs2 = Nothing
oRs.MoveNext
Wend
'Finally, close <chart> element
strXML = strXML & "</chart>"
Set oRs = nothing
'Create the chart - Pie 3D Chart with data from strXML
Call renderChart("MyWeb/includes/FCF_Pie2D.swf", "", strXML, "FactorySum", 650, 450)
%>
</BODY>
</HTML>
我在线路上收到一个运行时错误,显示如下:
设置oRs=oConnection.executesTquery
我似乎不知道我错在哪里。任何助手都将不胜感激。提前谢谢你 出现错误的原因是您的include文件DBConn.asp正在打开连接、关闭连接并将其设置为“无” 从DBConn.asp文件中删除:
oConnection.Close
Set oConnection = Nothing
更改您的代码:
'Create the recordset to retrieve data
Set oRs = Server.CreateObject("ADODB.Recordset")
'Generate the chart element
strXML = "<graph caption='Factory Output report' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"
'Iterate through each factory
strQuery = "select * from deal_price"
Set oRs = oConnection.Execute(strQuery)
While Not oRs.Eof
'Now create second recordset to get details for this factory
Set oRs2 = Server.CreateObject("ADODB.Recordset")
strQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" & ors("FactoryId")
Set oRs2 = oConnection.Execute(strQuery)
'Generate <set name='..' value='..'/>
strXML = strXML & "<set name='" & ors("FactoryName") & "' value='" & ors2("TotOutput") & "' />"
'Close recordset
Set oRs2 = Nothing
oRs.MoveNext
Wend
'Finally, close <chart> element
strXML = strXML & "</chart>"
Set oRs = nothing
'Create the chart - Pie 3D Chart with data from strXML
Call renderChart("../../FusionCharts/FCF_Pie3D.swf", "", strXML, "FactorySum", 650, 450)
'Create the recordset to retrieve data
Set oRs = Server.CreateObject("ADODB.Recordset")
'Generate the chart element
strXML = "<graph caption='Factory Output report' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"
'Iterate through each factory
strQuery = "select * from deal_price"
Set oRs = oConnection.Execute(strQuery)
While Not oRs.Eof
'Now create second recordset to get details for this factory
Set oRs2 = Server.CreateObject("ADODB.Recordset")
strQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" & ors("FactoryId")
Set oRs2 = oConnection.Execute(strQuery)
'Generate <set name='..' value='..'/>
strXML = strXML & "<set name='" & ors("FactoryName") & "' value='" & ors2("TotOutput") & "' />"
'Close recordset
Set oRs2 = Nothing
oRs.MoveNext
Wend
'Finally, close <chart> element
strXML = strXML & "</chart>"
Set oRs = nothing
'Create the chart - Pie 3D Chart with data from strXML
Call renderChart("../../FusionCharts/FCF_Pie3D.swf", "", strXML, "FactorySum", 650, 450)
'Add these lines back in as you are done processing your records
oConnection.Close
Set oConnection = Nothing
%>
出现错误的原因是,您的include文件DBConn.asp正在打开连接、关闭连接并将其设置为“无” 从DBConn.asp文件中删除:
oConnection.Close
Set oConnection = Nothing
更改您的代码:
'Create the recordset to retrieve data
Set oRs = Server.CreateObject("ADODB.Recordset")
'Generate the chart element
strXML = "<graph caption='Factory Output report' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"
'Iterate through each factory
strQuery = "select * from deal_price"
Set oRs = oConnection.Execute(strQuery)
While Not oRs.Eof
'Now create second recordset to get details for this factory
Set oRs2 = Server.CreateObject("ADODB.Recordset")
strQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" & ors("FactoryId")
Set oRs2 = oConnection.Execute(strQuery)
'Generate <set name='..' value='..'/>
strXML = strXML & "<set name='" & ors("FactoryName") & "' value='" & ors2("TotOutput") & "' />"
'Close recordset
Set oRs2 = Nothing
oRs.MoveNext
Wend
'Finally, close <chart> element
strXML = strXML & "</chart>"
Set oRs = nothing
'Create the chart - Pie 3D Chart with data from strXML
Call renderChart("../../FusionCharts/FCF_Pie3D.swf", "", strXML, "FactorySum", 650, 450)
'Create the recordset to retrieve data
Set oRs = Server.CreateObject("ADODB.Recordset")
'Generate the chart element
strXML = "<graph caption='Factory Output report' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"
'Iterate through each factory
strQuery = "select * from deal_price"
Set oRs = oConnection.Execute(strQuery)
While Not oRs.Eof
'Now create second recordset to get details for this factory
Set oRs2 = Server.CreateObject("ADODB.Recordset")
strQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" & ors("FactoryId")
Set oRs2 = oConnection.Execute(strQuery)
'Generate <set name='..' value='..'/>
strXML = strXML & "<set name='" & ors("FactoryName") & "' value='" & ors2("TotOutput") & "' />"
'Close recordset
Set oRs2 = Nothing
oRs.MoveNext
Wend
'Finally, close <chart> element
strXML = strXML & "</chart>"
Set oRs = nothing
'Create the chart - Pie 3D Chart with data from strXML
Call renderChart("../../FusionCharts/FCF_Pie3D.swf", "", strXML, "FactorySum", 650, 450)
'Add these lines back in as you are done processing your records
oConnection.Close
Set oConnection = Nothing
%>
您的DBConn.asp中是否定义了oConnection?亲爱的@andrew,我检查了变量,但仍然得到相同的错误..:您正在打开然后关闭连接,然后将其设置为Nothing。复制oConnection.Close并设置oConnection=Nothing,然后将其放在代码中的Set-oRs=oConnection.ExecuteStQuery之后。是否在DBConn.asp中定义了oConnection?亲爱的@andrew,我检查了变量,但仍然得到相同的错误..:您正在打开然后关闭连接,然后将其设置为Nothing。复制oConnection.Close并设置oConnection=Nothing,然后将其放在代码中的Set-oRs=oConnection.ExecuteStQuery之后。非常感谢您的帮助。我目前还不熟悉经典的asp,所以我很难发现这些愚蠢的错误。谢谢你的时间和帮助。非常感谢你的帮助。我目前还不熟悉经典的asp,所以我很难发现这些愚蠢的错误。谢谢你的时间和帮助。