Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to return database update errors to user

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-17 : 07:28:27
Elif writes "What is the best way to return database update errors to the user interface application? My user interface application and database acceess application are different software components that transform messages to each other. What is the best way to catch database errors, specially while updating the data in database, and return a meaningful error message to the user? Is it more suitable to try to catch possible errors (such as a primary key duplication during update) or can we return a meaningful error message from the error thrown by the sql server?

Thanks

Elif"

X002548
Not Just a Number

15586 Posts

Posted - 2003-07-17 : 09:56:44
Do mean @@ERROR <> 0 or @@ROWCOUNT = 0?



Brett

8-)
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-07-17 : 14:56:50
If you use ADO then you can send info-messages from your stored
procedures to clients, retrieving them from Connection.Errors collection:

CREATE PROCEDURE spInserter @i int
AS
if not exists(select 0 from ab where n=@i)
insert into ab select @i
else
print 'My meaningful message for the dummy'
return

In client code:

myConnection.Execute "exec spInserter 222"
For Each e In myConnection.Errors
Debug.Print e.Description
Next

- Vit
Go to Top of Page
   

- Advertisement -