[ASP ]請教 On Error Resume Next
不好意思 請教兩個問題
問題一.想請問 On Error Resume Next 這個東西要在怎樣的情況下使用
是看到某些錯誤嗎?還是?? 書上範例有些有加有些卻不用 搞不太懂@@
問題二.以下是某段程式碼 用途是 可以輸入SQL敘述去對ACCESS資料庫做處理
這段是從某書中某個範例中引用的 他也有用 OnErr....這個
但是我再跑的時候 發現下面藍色字那邊的判斷根本就有問題
都不可能跑出來 SQL 敘述執行成功(不過實際上有對資料庫動作)
我是沒跑過書中所附的檔 所以不曉得是他這樣寫法是錯的 還是我漏掉啥
書中主要是用SQL SERVER 2000 我是用 access...該不會是因為這個
如果是 那我該怎麼改才能判斷SQL是否執行正確
謝謝~
= = = = =
<%
On Error Resume Next
if Not IsEmpty(Resquest.Form) then
SQL_Command=Request("SQL_statement") 'SQL_statement就是SQL敘述
SQL_Command=LTrim(SQL_Command) '將左邊空白去除
'---取出SQL_Command左邊6個字母並轉換成大寫
Action_SQL=Ucase(Left(SQL_Command,6))
if Action_SQL="INSERT" or Action_SQL="DELETE" or Action_SQL="UPDATE" then
Session("CmdObj").CommandText=SQL_Command
'---執行Action Query類型的SQL敘述
Session("CmdObj").Execute
if Err.Number =0 then
Response.Write "SQL 敘述執行成功"
else
Response.Write "<Font Size=4 color=Red> SQL 敘述執行失敗</Font><br>"
Response.Write "原因:" & Err.description & Err.Number
end if
else
'---執行SQL敘述,並取得回傳的記錄集
set Session("RS") = Session("DBC").Execute(SQL_Command)
if Err.Number<>0 then
Response.Write "<br>" & Err.description
else
'---以下為顯示資料的程式
Display_RecordSet(Session("RS"))
end if
end if
else Response.Write "fail"
end if
%>
= = = = = = == = =
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.117.157.18
→
07/16 17:30, , 1F
07/16 17:30, 1F
→
07/16 17:31, , 2F
07/16 17:31, 2F