473,395 Members | 1,554 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,395 software developers and data experts.

handling errors from stored procs

Questions toward the bottom of the post.

Situation is this:

1) Access 97
2) SQL Server 2000
3) The Access app:
a) sets up pass-thru query
b) .SQL property of querydef is a string, the contents of which
comprise the call to a stored proc
c) in the Open event of the Access report object, sets
the .RecordSource property of the report object to the name of the
querydef
4) the stored proc:
a) accepts the parameters passed to it:
b) creates a string, the contents of which is a SQL SELECT
statement...the parameters passed to the stored proc comprise the the
WHERE clause
c) after creating the string (4b) do an exec() on the string; this
produces a result set that gets returned back to calling app
5) the result set produced by the stored proc populates the controls
in the Access report object

The situation described above is working

I would like to make the overall process more robust; to handle the
possibility that an error could occur when
the stored proc gets run...if so, it would be nice if the Access app
could display the message that describes
the error that happened when the stored proc was run.

For example, I deliberately set up the stored proc in such a way that
it would be syntactically correct, but when
it ran, it would produce an error (reminder: the sproc creates dynamic
SQL, then runs that SQL...so, in the
dynamically-created SQL, I deliberately misspelled a reference to a
column in a table. When I use the Query
Analyzer tool in SQL Server to run this stored proc, I see a
meaningful error message...a message along the
lines of "this column does not exist". When I run the exact same
stored proc through the Access app, the
result I see in Access is:

Reserved Error (-7711); there is no message for this error

I'm guessing that what's going on is:
a) the Access app was expecting a result set to get returned
b) the error in the stored proc means that the stored proc did not
return a result set
c) in the absence of a result set getting returned, Access issued the
-7711 error.

It would be great if I could set things up such that:
a) if there were no errors in stored proc, it would return the typical
result set
b) if there were errors in the stored proc, it would return the text
of the error message (e.g. the message "this
column does not exist")
c) the Access app would be smart enough to know when a result set got
returned, and it would then populate the
controls in the report
d) the Access app would be smart enough to recognize that what got
returned from stored proc was an error, and it would then report that
error

I realize that this posting contains some SQL Server elements and some
MS Access elements, and I realize that this is a group that deals with
MS Access-related topics. The questions below attempt to focus on
the MS Access stuff. As you can tell, the issue described above spans
the MS Access and SQL Server environments, so I'm hoping I'm not
violating posting protocol by referring to SQL Server in this post.

Questions:
1) Is it possible to set up set up an Access 97 app combined with a
SQL Server 2000 stored proc in such a way that:
- when stored proc runs without error, the result set that it
returns feeds RecordSource of Access report object
- when stored proc encounters error, it returns that error message
to Access app, and Access app displays that error message
?
2) If the answer to #1 is yes, how does one make the Access app smart
enough to distinguish between when a legitimate result set is getting
returned from stored proc vs when the stored proc is reporting an
error message?
3) If the answer to #1 is yes, is it likely that the stored proc will
have to employ an output parameter and make use of that parameter in
the instances when an error occurs while running the stored proc?

Thank you.
Jul 19 '08 #1
0 1954

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

Similar topics

1
by: Jon LaRosa | last post by:
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: ...
1
by: LineVoltageHalogen | last post by:
Greetings All, currentley there is a heated discussion in my place of work over which method is better/more efficient for simple selects. Background: 1.) Simple Application that uses sql server...
2
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data...
7
by: trint | last post by:
My boss wants me to use stored procedures, but I thought somehow that using c# that ADO.Net was better. Any help is appreciated. Thanks, Trint
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
1
by: kentk | last post by:
Is there a difference in how SQL Server 7 and SQL 2000 processes SQL passed from a program by an ADO command object. Reason I ask is I rewrote a couple applications a couple years ago were the SQL...
15
by: Burt | last post by:
I'm a stored proc guy, but a lot of people at my company use inline sql in their apps, sometimes putting the sql in a text file, sometimes hardcoding it. They don't see much benefit from procs, and...
8
by: Frank Calahan | last post by:
I've been looking at LINQ and it seems very nice to be able to make queries in code, but I use stored procs for efficiency. If LINQ to SQL only works with SQL Server and stored procs are more...
37
by: Sweetiecakes | last post by:
Hello I'm a bit confused on how one should handle exceptions. I'm currently building an ADO.NET Windows Forms application. I've built a class for manipulating data within the database in...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.