简体   繁体   English

如何在VBScript(经典ASP)中解决运行时错误('800a01a8')?

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

I have following classic asp code: 我有以下经典的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 file code: 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;"

I am getting a run time error on the line which says the following: Set oRs = oConnection.Execute(strQuery) . 我在行上遇到运行时错误,说明如下: 设置oRs = oConnection.Execute(strQuery)

I can not seem to work out, where I am going wrong. 我似乎无法解决,我出错的地方。 Any Assistant would be very much appreciated. 任何助理都将非常感激。 Thanks you in advance. 提前谢谢你。

The reason you are getting the error is because your include file (DBConn.asp) is opening the connection, closing it and setting it to Nothing. 您收到错误的原因是您的包含文件(DBConn.asp)正在打开连接,关闭它并将其设置为Nothing。

Remove from the DBConn.asp file: 从DBConn.asp文件中删除:

oConnection.Close
Set oConnection = Nothing

Change your code: 更改您的代码:

   '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