var i:integer=0; procedure tform1.raiseError; begin try DBIError(i); except on e:exception do begin self.Memo1.Lines.Add(e.Message); inc(i); end; end; end; procedure TForm1.FormCreate(Sender: TObject); var i:integer; begin for i:=0 to 1000 do begin raiseError; end; end; 怎么得到的结果是这些呀? An error occurred while attempting to initialize the Borland Database Engine (error $0000) An error occurred while attempting to initialize the Borland Database Engine (error $0001) An error occurred while attempting to initialize the Borland Database Engine (error $0002) An error occurred while attempting to initialize the Borland Database Engine (error $0003) An error occurred while attempting to initialize the Borland Database Engine (error $0004) An error occurred while attempting to initialize the Borland Database Engine (error $0005) An error occurred while attempting to initialize the Borland Database Engine (error $0006) An error occurred while attempting to initialize the Borland Database Engine (error $0007) An error occurred while attempting to initialize the Borland Database Engine (error $0008) An error occurred while attempting to initialize the Borland Database Engine (error $0009) An error occurred while attempting to initialize the Borland Database Engine (error $000A) 这些毫无意义呀!!!!!!!!!我哪里弄错了???????
procedure TForm1.FormCreate(Sender: TObject); var dbeError:EDBEngineError; i:integer; begin for i:=0 to 1000 do begin dbeError:=EDBEngineError.Create(i); self.Memo1.Lines.Add(dbeError.Message); end; end; 这段代码结果也一样
你能不能详细看看别人的回答啊?这样作:uses BDE;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); var pszError: PChar; I:integer; begin GetMem(pszError, MAXBYTE); for I :=0 to 100 do begin DbiGetErrorString(I, pszError); Memo1.Lines.Add(pszError); end; FreeMem(pszError); end;//dbeError:=EDBEngineError.Create(i); 只是改变了错误代码,并不会直接写入错误信息。————————————————————————————————— 宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。 —————————————————————————————————
他可以帮你!
通过调用BDE单元的:
function DbiGetErrorString (rslt: DBIResult; pszError: PChar): DBIResult stdcall;
也可以取得一个错误代码rslt对应的错误信息pszError。————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
i:integer=0;
procedure tform1.raiseError;
begin
try
DBIError(i);
except
on e:exception do begin
self.Memo1.Lines.Add(e.Message);
inc(i);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
for i:=0 to 1000 do begin
raiseError;
end;
end;
怎么得到的结果是这些呀?
An error occurred while attempting to initialize the Borland Database Engine (error $0000)
An error occurred while attempting to initialize the Borland Database Engine (error $0001)
An error occurred while attempting to initialize the Borland Database Engine (error $0002)
An error occurred while attempting to initialize the Borland Database Engine (error $0003)
An error occurred while attempting to initialize the Borland Database Engine (error $0004)
An error occurred while attempting to initialize the Borland Database Engine (error $0005)
An error occurred while attempting to initialize the Borland Database Engine (error $0006)
An error occurred while attempting to initialize the Borland Database Engine (error $0007)
An error occurred while attempting to initialize the Borland Database Engine (error $0008)
An error occurred while attempting to initialize the Borland Database Engine (error $0009)
An error occurred while attempting to initialize the Borland Database Engine (error $000A)
这些毫无意义呀!!!!!!!!!我哪里弄错了???????
var
dbeError:EDBEngineError;
i:integer;
begin
for i:=0 to 1000 do begin
dbeError:=EDBEngineError.Create(i);
self.Memo1.Lines.Add(dbeError.Message);
end;
end;
这段代码结果也一样
var
pszError: PChar;
I:integer;
begin
GetMem(pszError, MAXBYTE);
for I :=0 to 100 do
begin
DbiGetErrorString(I, pszError);
Memo1.Lines.Add(pszError);
end;
FreeMem(pszError);
end;//dbeError:=EDBEngineError.Create(i);
只是改变了错误代码,并不会直接写入错误信息。—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————