BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

passing SQL error to D7

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Keith G Hicks
Guest





PostPosted: Tue Feb 15, 2005 2:41 am    Post subject: passing SQL error to D7 Reply with quote



I have a trigger in MS SQL 2000 where I raise an error if a field cannot be
deleted. In my ADO Dataset OnDeleteError code a really grungy message pops
up telling me there's an error and part of the message includes the text of
my raise error in the back end. I want to pull that out but can't figure out
how to make use of things like EOleException (not sure I'm on the right
track anyway). Can anyone lend me some advice here or point me in the right
direiction for passsing error messages from MS SQL 2000 to a D7 front end
app?

Thanks,

Keith


Back to top
Keith G Hicks
Guest





PostPosted: Tue Feb 15, 2005 4:03 am    Post subject: Re: passing SQL error to D7 Reply with quote



But I want the front end to retrieve the error text that's actually in the
backend. I don't want to recreate it in the front end.

"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote


Quote:
I have a trigger in MS SQL 2000 where I raise an error if a field cannot be
deleted. In my ADO Dataset OnDeleteError code a really grungy message pops
up telling me there's an error and part of the message includes the text of
my raise error in the back end. I want to pull that out but can't figure
out
how to make use of things like EOleException (not sure I'm on the right
track anyway). Can anyone lend me some advice here or point me in the right
direiction for passsing error messages from MS SQL 2000 to a D7 front end
app?
You can just change e.Message to any text you want

--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]



Back to top
Heinrich Braun
Guest





PostPosted: Tue Feb 15, 2005 1:02 pm    Post subject: Re: passing SQL error to D7 Reply with quote



Hi Keith,

you get the SQL-error-text from your ado-connection object.



....
if E is EDatabaseError
then
begin
estr:='';
for i:=0 to dm1.ADOConnection_Mydb.Errors.Count -1
do
begin
errorno := dm1.ADOConnection_Mydb.Errors.Item[i].NativeError;
estr:= format('%s
%s,%s,%d',[estr,dm1.ADOConnection_Mydb.Errors.Item[i].Source,dm1.ADOConnection_Mydb.Errors.Item[i].Description,errorno]
);
end;

//do something with estr
end;
....


hope this helps

Heinrich



Keith G Hicks schrieb:
Quote:
But I want the front end to retrieve the error text that's actually in the
backend. I don't want to recreate it in the front end.

"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote in message
news:l3s211lchn7kjknft8b2ras3mec9g18a0e (AT) 4ax (DOT) com...


I have a trigger in MS SQL 2000 where I raise an error if a field cannot be
deleted. In my ADO Dataset OnDeleteError code a really grungy message pops
up telling me there's an error and part of the message includes the text of
my raise error in the back end. I want to pull that out but can't figure

out

how to make use of things like EOleException (not sure I'm on the right
track anyway). Can anyone lend me some advice here or point me in the right
direiction for passsing error messages from MS SQL 2000 to a D7 front end
app?

You can just change e.Message to any text you want
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]



Back to top
Keith G Hicks
Guest





PostPosted: Tue Feb 15, 2005 7:16 pm    Post subject: Re: passing SQL error to D7 Reply with quote

Severity Level is the actual answer on this. It's just a matter of setting
that high enough so that SQL will actually pass the information to Delphi.
If it's too low, then e.message won't even see the SQL message.

Keith


Back to top
Keith G Hicks
Guest





PostPosted: Wed Feb 16, 2005 3:49 pm    Post subject: Re: passing SQL error to D7 Reply with quote

Good suggestion. I've actually done that in VB work before. I found it was
the only way to get the actual text and not all the other stuff that comes
along with it. It works well. But in doing all this stuff with Delphi
recently I've found that the errror text is much easier to get at than I'm
used to. I started out doign what you suggested and discovered it was
redundant. If I set the severity level of the raiserror in sql to anythign
between 11 and 16, then the message text gets passed just fine and I can get
it from e.message. It's actually pretty simple. Thanks for the advice. :)

Keith

"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote


Quote:
But I want the front end to retrieve the error text that's actually in the
backend. I don't want to recreate it in the front end.

The I suggest you put some kind of delimiters around your error message that
you
can use to parse your error out of the string returned.


--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.