fischermx
asked on
How to shutp Delphi ADO exceptions?
So, I have this simple code:
try
Table1.Post;
except
end;
And I expect, that no matter what happen on the Post even, i get no errors and move on. Since I have this in a loop (of course I will add some more logic later for the real app).
But, I still getting a message box with the error.
And I don't get it why. I'm running this outside Delphi, so there's nothing to change in the debugger options (which I already tried anyway).
I'm using Delphi 5 and Ado components.
Any idea?
try
Table1.Post;
except
end;
And I expect, that no matter what happen on the Post even, i get no errors and move on. Since I have this in a loop (of course I will add some more logic later for the real app).
But, I still getting a message box with the error.
And I don't get it why. I'm running this outside Delphi, so there's nothing to change in the debugger options (which I already tried anyway).
I'm using Delphi 5 and Ado components.
Any idea?
remove try and except ....
or ...
except
try Post;
except
end;
except
try Post;
except
end;
What happens if you put an "on E: Exception..." handler in to your except, does that kill the error?
Outside of that, are you sure this is the code generating/showing the error?
Outside of that, are you sure this is the code generating/showing the error?
try
Table1.Post;
except
on E: Exception do
begin
//eat the error
end;
end;
you do not normally use try except in posting to tables because they have their own error routines.
but if you generate error then you must know what the error is...
but if you generate error then you must know what the error is...
ASKER
@senad:
Thanks for your effort in asking this, but your answer is... well, I don't know.
@irishbuddah:
Thanks for your answer. I actually have my code the exact way you have it, and I still get an error.
Thanks for your effort in asking this, but your answer is... well, I don't know.
@irishbuddah:
Thanks for your answer. I actually have my code the exact way you have it, and I still get an error.
Hi fischermx,
You have to know which error raised, so this code may help you
try
Self.ADOTable1.Post;
except
ShowMessage(IntToStr(Self. ADOConnect ion1.Error s[0].Nativ eError) + #13 +
Self.ADOConnection1.Errors [0].Descri ption);
end;
also you may use "NativeError" to trap the errors
Regards,
Khalid
You have to know which error raised, so this code may help you
try
Self.ADOTable1.Post;
except
ShowMessage(IntToStr(Self.
Self.ADOConnection1.Errors
end;
also you may use "NativeError" to trap the errors
Regards,
Khalid
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are right. The error was not the post, I just couldn't see it.
As I told, this code was a loop.
So, at the top, when a new insert was attempted, that was the code that raised the error.
I just added "Table1.Cancel" in my except section and all worked fine.
Thanks!
As I told, this code was a loop.
So, at the top, when a new insert was attempted, that was the code that raised the error.
I just added "Table1.Cancel" in my except section and all worked fine.
Thanks!