ASP 錯誤! 當物件關閉時,不允許操作!

2011-12-21 8:04 pm
VBScript 發生錯誤:錯誤號碼:3704錯誤說明:當物件關閉時,不允許操作。錯誤輔助說明:1240653錯誤來源:Microsoft VBScript 執行階段錯誤

why?


source code

------------------------------------------------------------------------------------------
<html>
<body>
<!--#include file="databaseFunctions.asp"-->
<%On Error Resume Next 'Dim strStockID,strMemberID,strPrice,strOrder_num,strOrder_name,strOrder_tel,strReceive_name,strReceive_tel,strReceive_address,strPayment,strDatestrorder_name = Request.Form("order_name")
strorder_tel = Request.Form("order_tel")
strReceive_name = Request.Form("receive_name")
strReceive_tel = Request.Form("receive_tel")Set objRS = Server.CreateObject("ADODB.RecordSet")
sql = "select * from order"
objRS.Open sql,objDBConn,1 ,3objRS.AddNew
objRS.Fields("stockID") = session("StockID")
objRS.Fields("loginID") = session("LoginID")
objRS.Fields("sprice") = session("Price")
objRS.Fields("order_num") = session("order_num")
objRS.Fields("order_name") = strorder_name
objRS.Fields("order_tel") = strorder_tel
objRS.Fields("receive_name") = strReceive_name
objRS.Fields("receive_tel") = strReceive_tel
objRS.Update

If Err.Number > 0 Then
Response.Write "VBScript 發生錯誤:" & "<P>"
Response.Write "錯誤號碼:" & Err.Number & "<P>"
Response.Write "錯誤說明:" & Err.Description & "<P>"
Response.Write "錯誤輔助說明:" & Err.Helpcontext & "<P>"
Response.Write "輔助說明路徑" & Err.Helppath & "<P>"
Response.Write "原始錯誤:" & Err.Nativeerror & "<P>"
Response.Write "錯誤來源:" & Err.Source & "<P>"
Response.Write "SQL語法:" & Err.Sqlstate & "<P>"
End If
If objDBConn.Errors.Count > 0 Then
Response.Write "資料庫發生錯誤"&"<p>"
For intCounter = 0 to objDBConn.Errors.Count
Response.write.write "錯誤碼:"&_
objDBConn.Errors(intCounter).Number & "<P>"
Response.write "錯誤說明:"&_
objDBConn.Errors(intCounter).Description & "<p>"
Next.......%>

回答 (1)

2011-12-23 9:39 am
✔ 最佳答案
因為不知錯誤出在那一行,只能從錯誤說明估計。

在執行
objRS.Open sql,objDBConn,1 ,3
這指令時,
objDBConn 並未開啟
objDBConn.Open 指令並未執行。

建議將 On Error Resume Next 暫時除去,就可知出錯在那一行。


收錄日期: 2021-04-11 18:52:17
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20111221000051KK00230

檢視 Wayback Machine 備份