473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

help with error handling

Hi all -

I have a web application and I want to be able to do some basic error
handling. For example, here is one error I would like to catch and
display in a useful way for the user:
-----------------
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]UPDATE statement
conflicted with COLUMN FOREIGN KEY constraint
'FK_tbl_DemographicInfo_tbl_LookupCurrentLiving'. The conflict occurred
in database 'asian_task_force', table 'tbl_LookupCurrentLiving', column
'Code'.

/ASAPOnline/demoProcess.asp, line 271
-----------------

The error is straightforward to you and me. People reading this
newsgroup know why this error would occur and what it means. What is
not straightforward is how I can get the relevant info I need from the
error and return it to the user.

BTW, the line referenced, line 271, is a call to a stored procedure:
cmd.Execute
[cmd is set up as:
set cmd = Server.CreateObject("ADODB.Command")]

An end user is not going to know what this error means. What I would
really like to be able to do is to determine that it's a foreign key
contrainst error and tell the user which field/table is causing the
error. If I can't get the actual table/field easily, I would like to
at least be able to determine that it's a foreign key constraint and
provide some text to the that explains what the heck that means in
plain english.

My problem is that I don't even know where to do this. I tried doing
this in the ASP code, and I was able to get this much:
---------------
Description: [Microsoft][ODBC SQL Server Driver][SQL Server]UPDATE
statement conflicted with COLUMN FOREIGN KEY constraint
'FK_tbl_DemographicInfo_tbl_LookupCurrentLiving'. The conflict occurred
in database 'asian_task_force', table 'tbl_LookupCurrentLiving', column
'Code'.
HelpContext: 0
helpfile:
number: -2147217900
Source: Microsoft OLE DB Provider for ODBC Drivers
---------------

which is from the Err object that ASP returns. Still though, the fact
that it's a foreign key constraint error and the tables that are
involved are burried in the Err.Description text.

So would I be able to break this info out in my stored proc? I know
the message for the error is in the sysmessages table, in this case:
----------
%ls statement conflicted with %ls %ls constraint '%.*ls'. The conflict
occurred in database '%.*ls', table '%.*ls'%ls%.*ls%ls.
----------

Is there any way I can get access to these "%ls" variables and then do
something with them? If so, where would I do this, in the stored proc,
in the ASP code, or elsewhere? Or is this an issue in the nebulous
region (read: the region I know very little about) of ODBC/OLE or ADO?
Help!

thanks in advance,
jon
jlarosa at alumni dot brown dot edu

Jul 23 '05 #1
0 1456

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WSeeger | last post by:
When creating a new class, is it encouraged to always include error handling routines within your LET and GET procedures? It's seems that most text books never seem to include much about error...
1
by: Bill S. | last post by:
Hi, I a stored procedure that inserts a record into a table as below. The insert works OK, but if the insert violates a unique indewx constraint on one of the columns, the proc terminates...
1
by: June Moore | last post by:
Hi, I am getting an error with the following code. Error is: ADODB.Connection error '800a0e78' - The operation requested by the application is not allowed if the object is closed. Any ideas how...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Mike | last post by:
Greetings, Having a major problem here. running version 8.2 on win2003 server. The problem I am having is backing up a database seems to get to the last part of the backup and then fails. This...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
0
by: Kamal Dhingra | last post by:
Hi Guys, I am developing an asp.net application .In error handling , I have 2 web.congif files ,one is in Web(which is the virtual directory) ,other i have created in a folder in Web/Admin. The...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
9
by: MrDeej | last post by:
Hello guys! We have an SQL server which sometimes makes timeouts and connection errors. And we have an function witch writes and updates data in 2 tables on this server. When the SQL server error...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.