473,569 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error Code from SQL Server2000

How can I return an error code from a sql server stored procedure and use it
in my asp page to generate an alert indicating that some error has ocurred?
Jul 22 '05 #1
6 2391
amitavabardhan wrote:
How can I return an error code from a sql server stored procedure and
use it in my asp page to generate an alert indicating that some error
has ocurred?


An error in a procedure should raise a vbscript error. Also, it should show
up in your connection object's Errors collection.

Check out the two articles about error-handling on this site:
http://www.sommarskog.se/index.html

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2
what I actually meant was that when I am calling a Sql Server stored
procedure from an asp page, then if an error occurs during execution of the
stored procedure, under such circumstances how can I capture that error in
the asp page so as to generate an error message and stop program execution.

"amitavabardhan " wrote:
How can I return an error code from a sql server stored procedure and use it
in my asp page to generate an alert indicating that some error has ocurred?

Jul 22 '05 #3
amitavabardhan wrote:
what I actually meant was that when I am calling a Sql Server stored
procedure from an asp page, then if an error occurs during execution
of the stored procedure, under such circumstances how can I capture
that error in the asp page so as to generate an error message and
stop program execution.


Same answer. Explain why the answer is not sufficient. Do you kinow how to
use On Error Resume Next to trap errors?

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #4
Yes, but how do I return an error message/ code from a sql server stored
procedure to an asp page?

"amitavabardhan " wrote:
How can I return an error code from a sql server stored procedure and use it
in my asp page to generate an alert indicating that some error has ocurred?

Jul 22 '05 #5
Are you replying to me? Please quote some of the message to which you are
replying.
amitavabardhan wrote:
Yes, but how do I return an error message/ code from a sql server
stored procedure to an asp page?


Again, errors are returned automatically to the ADO Connection, which
automatically bubbles them up to the vbscript runtime, which creates an Err
object containing the information, which you can trap using "On Error Resume
Next".
On Error Resume Next
connection.Stor edProcedureName parm1,..,parmN
If err <> 0 then
'handle the error
errmsg= err.description
'optionally, check the connection's Errors collection:
if connection.Erro rs.Count > 0 then
for i = 0 to connection.Erro rs.Count - 1
errmsg=connecti on.Errors(i).De scription
'etc.
next
end if
end if
The reason for checking the Errors collection is that in some cases,
multiple errors may be returned from the procedure. Only the first error
gets bubbled up to the vbscript runtime. The rest will be found in the
connection's errors collection.

Here is a link to the download location for the vbscript documentation:
http://tinyurl.com/7rk6

You can read the ADO documentation online at:
http://msdn.microsoft.com/library/en...dooverview.asp

Here is some more information about executing stored procedures from ASP:
http://tinyurl.com/jyy0

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #6
Yes Bob, I was replying to you. My sincere apologies for leaving you in
cold....
Thanks for the piece of code on error trapping from stored procedures. I
definitely appreciate you help on this.
"Bob Barrows [MVP]" wrote:
Are you replying to me? Please quote some of the message to which you are
replying.
amitavabardhan wrote:
Yes, but how do I return an error message/ code from a sql server
stored procedure to an asp page?


Again, errors are returned automatically to the ADO Connection, which
automatically bubbles them up to the vbscript runtime, which creates an Err
object containing the information, which you can trap using "On Error Resume
Next".
On Error Resume Next
connection.Stor edProcedureName parm1,..,parmN
If err <> 0 then
'handle the error
errmsg= err.description
'optionally, check the connection's Errors collection:
if connection.Erro rs.Count > 0 then
for i = 0 to connection.Erro rs.Count - 1
errmsg=connecti on.Errors(i).De scription
'etc.
next
end if
end if
The reason for checking the Errors collection is that in some cases,
multiple errors may be returned from the procedure. Only the first error
gets bubbled up to the vbscript runtime. The rest will be found in the
connection's errors collection.

Here is a link to the download location for the vbscript documentation:
http://tinyurl.com/7rk6

You can read the ADO documentation online at:
http://msdn.microsoft.com/library/en...dooverview.asp

Here is some more information about executing stored procedures from ASP:
http://tinyurl.com/jyy0

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 22 '05 #7

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

Similar topics

1
5076
by: Martin Feuersteiner | last post by:
Dear Group I'm having a very weird problem. Any hints are greatly appreciated. I'm returning two values from a MS SQL Server 2000 stored procedure to my ASP.NET Webapplication and store them in sessions. Like This: prm4 = cmd1.CreateParameter With prm4
3
39264
by: laurenq uantrell | last post by:
I am trying to install SQL Server 2000 on a Win2K OS machine but I get this error message: "A previous program installation created pending file operations on the installation machine. You must restart the computer before running setup." I see others have had this problem but have fixed it using the solution in:
0
1179
by: CAIBird | last post by:
hi, i've been developing a webservice on machine A and one WebMethod of this webservice will connect to SQL Server2000 on machine B using a connect string defined in Web.config as below: <add key="sqlDbConn.ConnectionString" value="workstation id="172.23.171.226";packet size=4096;integrated security=SSPI;data...
6
2163
by: gabrielvarun | last post by:
Hello everybody, Thanks for everybody who tries to help me out. I need code for connecting to a remote database(Sql server2000) through the vb.net 2003. The sql server will be placed remotely outside the lan. Please help me. Yours Faith fully, Varun. sd/-
4
4114
by: dgh111 | last post by:
help me one organisation generate one utility in VB programme on NT Server2000 platform and running perfactily. When I change me PC on XP environment and install that utility and running that it is give me Run-Time error -2147467259(80004005) Automation error and unspecified error I could not understand that is problem me access database...
3
9191
by: dgh111 | last post by:
I Could not understand that where is the problem. Some agency make one small programme for me in NT Server2000 platform and is working properly. But when I change my PC in XP environment that utililty not working so I could not understand when I run it give me above runtime error. Either may be access database or VB programme may be problem. ...
1
4641
by: krndhi1983 | last post by:
Hi to All, I am using Windows XP running IIS 6.0.I am developing a project using vb.net 1.1 with SQL Server 2000.It is a mobile project.So i am also using Pocket PC 2002 with SQL CE 2.0.When I want to Pull the table from SQL Server 2000 to SQL CE the following error will be occured. The Error is the request to send data to the computer...
0
830
by: abhishektech | last post by:
how to call a table from ms access to sql server2000 through coding in sql server2000 query analyzer
1
2209
by: mukeshrasm | last post by:
Hi while restoring database in sql server2000/2005 I am getting this error message: The media set for database nhrc has 2 family members but only 1 are provided. All Members must be provided.RESTORE DATABASE is terminating abnormally. what does this error means and how can I find out the solution.
0
7695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.