簡體   English   中英

如何在VBScript(經典ASP)中解決運行時錯誤('800a01a8')?

[英]How to resolve runtime error ('800a01a8' ) in VBScript (classic ASP)?

我有以下經典的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 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>

DBconnection文件代碼:

Dim oConnection
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=SQLOLEDB; Data Source=MA-PC\SQLEXPRESS; Initial      Catalog=test; User ID=missy; Password=hello;"

我在行上遇到運行時錯誤,說明如下: 設置oRs = oConnection.Execute(strQuery)

我似乎無法解決,我出錯的地方。 任何助理都將非常感激。 提前謝謝你。

您收到錯誤的原因是您的包含文件(DBConn.asp)正在打開連接,關閉它並將其設置為Nothing。

從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

 %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM