(1)什么错误表示服务器失败?
(2)数据库(SQL Server, ADO)错误代码与HResult关系?
(3)那些范围可以自定义使用?
(2)数据库(SQL Server, ADO)错误代码与HResult关系?
(3)那些范围可以自定义使用?
解决方案 »
- 数据库主键冲突,异常处理,请高手给看看(新手菜鸟问题)
- VCL程序报错,请大虾赐教。
- 点击按钮,触发方向键
- 在线:关于TRealAudio控件无法播放Tmemorystream的问题(难道该控件只能关联调用吗???)......
- 有没有谁能回答一个问题
- 关于Richedit的两个问题
- 大家来看看微软能接受的对delphi3 vb5 pb5的评价
- 关于mdi界面--希望各位老大帮忙
- delphi_6真的到了吗?天津地区可不可以买到?
- DBGrid的ShowHint和ParentShowHint有什麽区别?
- TdxDBGrid 控件!!(在线等)
- 请问哪里有delphi第三方控件开发和使用的书籍下载啊?
The following HRESULT values are defined in the System unit:Constant Hex. Value MeaningS_OK 00000000 No error. In some APIs, S_OK indicates a successful operation with a return value of true.
S_FALSE 00000001 No error, but operation did not produce a useful result. In some APIs, S_FALSE indicates a successful operation with a return value of false.
E_INTERFACE 80004002 Interface not supported.
E_UNEXPECTED 8000FFFF Catastrophic failure
E_NOTIMPL 80004001 Operation not implementedNote that in the above constant names, the S_ and E_ prefixes correspond to the value of the Severity bit.The following HRESULT values are defined in the Types unit (Linux) or Windows unit (Windows):Constant Hex. Value MeaningE_FAIL 80004005 Unspecified error.STG_E_INVALIDFUNCTION 80030001 Unable to perform storage management function.
STG_E_FILENOTFOUND 80030002 File not found.
STG_E_PATHNOTFOUND 80030003 Path not found.
STG_E_TOOMANYOPENFILES 80030004 Insufficient resources to open another file.
STG_E_ACCESSDENIED 80030005 Access denied.
STG_E_INSUFFICIENTMEMORY 80030008 Insufficient memory to complete storage operation.
STG_E_NOMOREFILES 80030012 No more files to return.
STG_E_DISKISWRITEPROTECTED 80030013 Disk is write-protected.STG_E_SEEKERROR 80030019 Error during seek.
STG_E_LOCKVIOLATION 80030021 Lock violation.
STG_E_FILEALREADYEXISTS 80030050 File already exists.
STG_E_INVALIDPARAMETER 80030057 Invalid parameter.
STG_E_MEDIUMFULL 80030070 Disk full.
STG_E_INVALIDNAME 800300FC Invalid name.
Note that an additional prefix is added to HRESULT constant names to indicate a non-zero Facility Code. In the above examples, the STG_ prefix and the Facility Code 3 both indicate storage errors.和数据库的errorcode应该没有直接的联系
(1)我想确定服务器失败,总不能按李维所例,
凡OleSysError都视为服务器失败吧。
(2)数据库操作异常时错误代码是否转换成对应的HResult,
以便在Client判断。
(3)用系统未使用的错误代码,自定义含义,以便在Client
做出相应处理。
-----------------
uses ComServ;const
CODE_BASE = $200; //recommended codes are from 0x0200 - 0xFFFFprocedure TFoo.Bar;
begin
//can be assigned once (globally) from somewhere
ComServer.HelpFileName := 'HelpFile.hlp'; //help file
//raise error: message='Error Message', number=5 + CODE_BASE, help context=1
raise EOleSysError.Create (
'Error Message', //error message
ErrorNumberToHResult (5 + CODE_BASE), //HRESULT
1 //help context
);
end;function ErrorNumberToHResult (ErrorNumber : integer) : HResult;
const
SEVERITY_ERROR = 1;
FACILITY_ITF = 4;
begin
Result := (SEVERITY_ERROR shl 31) or (FACILITY_ITF shl 16) or word (ErrorNumber);
end;
-----------------
client
-----------------
const
CODE_BASE = $200; //recommended codes are from 0x0200 - 0xFFFFprocedure CallFooBar;
var
Foo : IFoo;
begin
Foo := CoFoo.Create;
try
Foo.Bar;
except
on E : EOleException do
ShowMessage ('Error message: ' + E.Message + #13 +
'Error number: ' + IntToStr (HResultToErrorNumber (E.ErrorCode) - CODE_BASE) + #13 +
'Source: ' + E.Source + #13 +
'HelpFile: ' + E.HelpFile + #13 +
'HelpContext: ' + IntToStr (E.HelpContext)
);
end;
end;function HResultToErrorNumber (hr : HResult) : integer;
begin
Result := (hr and $FFFF);
end;
非常感谢!!! 而我睡了一个懒觉,不好意思。今天继续工作,我试试看:
主要是确定服务器失败,以便做容错处理。