三層架構,中間例外如何欄截? |
缺席
|
shunchia63
高階會員 發表:26 回覆:141 積分:198 註冊:2007-05-22 發送簡訊給我 |
我在測試一個程式 架構如下 DB MSSQL2K <-----> 中間層 TRemoteDataModule ( TADOConnection TADOQuery TDataSetProvider([poAllowCommandText]) ) <------>用戶端(TClientDataSet ) 當我用 self.ClientDataSet1.Close; self.ClientDataSet1.CommandText := 'insert into Tabxxx values('A','A')'; self.ClientDataSet1.Execute(); CASE: 當DB Key 重覆時 [中間層 ] 會引發中間層 TADOQuery 錯誤訊息 ,(無法處理此訊息,需人工點掉,錯誤才會Pass到 用戶端(TClientDataSet ) ) [用戶端 ] 收到 - 錯誤訊息 我的問題 TADOQuery 如何欄截此例外? (TADOQuery onXXXXError )我有寫Debug Code 但無法進入.中間層 也沒機會 try catch... Call Stack Information: ------------------------------------------------------------------------------------------- |Address |Module |Unit |Class |Procedure/Method |Line| ------------------------------------------------------------------------------------------- |400091ED|rtl60.bpl |System.pas | |_CheckAutoResult | | |400091DC|rtl60.bpl |System.pas | |_CheckAutoResult | | |4064C2DD|adortl60.bpl |Adodb.pas |TADOCommand |Execute | | |4064C248|adortl60.bpl |Adodb.pas |TADOCommand |Execute | | |4064C224|adortl60.bpl |Adodb.pas |TADOCommand |Execute | | |4064C20C|adortl60.bpl |Adodb.pas |TADOCommand |Execute | | |40654058|adortl60.bpl |Adodb.pas |TCustomADODataSet|PSExecute | | |402E54CE|dsnap60.bpl |Provider.pas |TCustomProvider |Execute | | |402E5490|dsnap60.bpl |Provider.pas |TCustomProvider |Execute | | |402EC71B|dsnap60.bpl |Databkr.pas |TRemoteDataModule|AS_Execute | | |77105D7F|oleaut32.dll | | |DispCallFunc | | |77105CBE|oleaut32.dll | | |DispCallFunc | | |77134E25|oleaut32.dll | | |DispInvoke | | |77134E05|oleaut32.dll | | |DispInvoke | | |7C9210ED|ntdll.dll | | |RtlLeaveCriticalSection| | |77ED4005|RPCRT4.dll | | |NdrStubCall2 | | |77D2E04C|user32.dll | | |GetMessageA | | |77D196C2|user32.dll | | |DispatchMessageA | | |77D196B8|user32.dll | | |DispatchMessageA | | |4003646C|rtl60.bpl |Classes.pas |TThread |Resume | | |40036464|rtl60.bpl |Classes.pas |TThread |Resume | | |400361C6|rtl60.bpl |Classes.pas |TThread |AfterConstruction | | |40005B10|rtl60.bpl |System.pas | |_AfterConstruction | | |4003CF37|rtl60.bpl |Vclcom.pas |TComponentFactory|CreateInstance | | |7C9210ED|ntdll.dll | | |RtlLeaveCriticalSection| | |77DA8A92|advapi32.dll | | |MD4Final | | |7C92304B|ntdll.dll | | |RtlCompareMemoryUlong | | |7C9306E6|ntdll.dll | | |RtlAllocateHeap | | |77ED4005|RPCRT4.dll | | |NdrStubCall2 | | |77E5602D|RPCRT4.dll | | |NdrTypeFlags | | |77D196C2|user32.dll | | |DispatchMessageA | | |77D196B8|user32.dll | | |DispatchMessageA | | |400F582F|vcl60.bpl |Forms.pas |TApplication |ProcessMessage | | |400F57AC|vcl60.bpl |Forms.pas |TApplication |ProcessMessage | | |400F585C|vcl60.bpl |Forms.pas |TApplication |HandleMessage | | |400F5A86|vcl60.bpl |Forms.pas |TApplication |Run | | |400F59F0|vcl60.bpl |Forms.pas |TApplication |Run | | |00422E5A|RemitService.exe|RemitService.dpr| | |18 | |7C92E64C|ntdll.dll | | |NtSetInformationThread | | ------------------------------------------------------------------------------------------- 編輯記錄
shunchia63 重新編輯於 2007-10-22 01:07:43, 註解 無‧
|
shunchia63
高階會員 發表:26 回覆:141 積分:198 註冊:2007-05-22 發送簡訊給我 |
自己改Source code 刪除 C:\Program Files\Borland\Delphi6\Lib\Provider.dcu 刪除 C:\Program Files\Borland\Delphi6\Lib\debug\Provider.dcu My change code . unit Provider; procedure TDataSetProvider.InternalExecute(const CommandText: WideString; var Params: OleVariant); begin try CheckDataSet; IProviderSupport(DataSet).PSExecute; except on e:exception do begin raise ; end; end; |
shunaaron
高階會員 發表:13 回覆:94 積分:106 註冊:2006-10-06 發送簡訊給我 |
procedure TColckSys.BaseSelect(const BaNa: WideString; out BaAy,
BaAc: OleVariant; out ppstr: WideString); Var SQL:String; i,j:Integer; begin Try SQL:=''; ADODataSet1.Close; SQL:='Select * From ' BaNa ADODataSet1.CommandText:=SQL; ADODataSet1.Open; BaAy:=VarArrayCreate([0,ADODataSet1.FieldCount-1,0,ADODataSet1.RecordCount],VarVariant); BaAc:=ADODataSet1.RecordCount; For i:= 0 To ADODataSet1.RecordCount-1 Do Begin For j:= 0 To ADODataSet1.FieldCount-1 Do BaAy[j,i]:=VarToStr(ADODataSet1.FieldList.Fields[j].Value); ADODataSet1.Next; End; except on E : Exception do ppStr := E.Message; End; end; 這是在COM元件所寫的程式碼 在Method多設一個回傳的String即可 在AP程式在判斷 ppstr是否為空字串 如果否代表有錯誤訊息
------
程式沒有這麼難 只是還沒打通其中要絕 |
shunchia63
高階會員 發表:26 回覆:141 積分:198 註冊:2007-05-22 發送簡訊給我 |
我直接引用 Provider故無實作 Method
有3個Case需要欄截 client 1.SQL SELECT 語法不引用參數 2.SQL SELECT 語法 引用參數 3.SQL insert 語法 引用參數 對應的Prioder方法都要try catch掉 目前直接改Source Code 攔截 似乎delphi6 BUG?? 沒Pass到Client delphi 6 XP MS SQL 2K
編輯記錄
shunchia63 重新編輯於 2007-11-08 12:23:41, 註解 無‧
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |