寫一個函數在datawindow的dberror事件中調用函數如下﹕(這是在判斷Oracle出錯時用的) long ll_pos CHOOSE CASE ai_sqlcode CASE 1 messagebox(" 輸入資料錯誤~","輸入資料不能重覆") CASE 2 messagebox(" 輸入資料錯誤~","輸入資料不能為空白") CASE 1400 messagebox(" 輸入資料錯誤~","輸入資料不能為空白") CASE 1438 messagebox(" 輸入資料錯誤~","輸入資料超過精確度") CASE 2291 messagebox(" 輸入資料錯誤~","參照來源資料不存在,請先建立來源資料") CASE 2292 messagebox(" 輸入資料錯誤~","刪除或修改的資料,已經被其他作業~使用到,無法修改或刪除") CASE 20002 ll_pos = pos(as_sqlerrtext,"ORA-06512") Messagebox("輸入資料錯誤~",Left(as_sqlerrtext,ll_pos - 1)) CASE ELSE // messagebox("出錯代號:"+string(ai_sqlcode), as_sqlerrtext) END CHOOSEreturn 1 // suppress the default message
...err:
If InStr(Err.Description, "Violation of PRIMARY KEY") > 0 Then
msgbox "主鍵重復"
err.clear
end if
...
頂多用PRINT用你自己用程式來實現.
如果涉及到存储过程,建议使用raiserror;
long ll_pos
CHOOSE CASE ai_sqlcode
CASE 1
messagebox(" 輸入資料錯誤~","輸入資料不能重覆")
CASE 2
messagebox(" 輸入資料錯誤~","輸入資料不能為空白")
CASE 1400
messagebox(" 輸入資料錯誤~","輸入資料不能為空白")
CASE 1438
messagebox(" 輸入資料錯誤~","輸入資料超過精確度")
CASE 2291
messagebox(" 輸入資料錯誤~","參照來源資料不存在,請先建立來源資料")
CASE 2292
messagebox(" 輸入資料錯誤~","刪除或修改的資料,已經被其他作業~使用到,無法修改或刪除")
CASE 20002
ll_pos = pos(as_sqlerrtext,"ORA-06512")
Messagebox("輸入資料錯誤~",Left(as_sqlerrtext,ll_pos - 1))
CASE ELSE
// messagebox("出錯代號:"+string(ai_sqlcode), as_sqlerrtext)
END CHOOSEreturn 1 // suppress the default message
f_dberror(sqldbcode, sqlerrtext)//關閉系統錯誤提示
return 1
使用分层的程序很诱人,但小规模的程序还是用单层更划算。还有如果我想学习
分层的数据库程序设计,有哪些好书,请各位大虾不吝赐教。