469,271 Members | 1,778 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

ASP Error Handling

Dear all,

this error handling has been a pain since so manya days

using ASP 3.0 with IIS 5.0 on W2K server Created a custom error page
using the Server.GetLastError() and works fine in most of the cases.
Following are the issues :
1. Have a hughe file (5-6 mb approx) to upload, now if there are any
errors during upload i want to immediately throw an error and roll back
the transaction.
2. When the following error occurs, am not redirected to the custom
error page bu the same is displayed on the same page.
Error -
Microsoft OLE DB Provider for SQL Server error '80040e21'

Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.

is there a way to trap the above error using the Server.GetLastError on
the custom error page

Pls help...

Thanks & Regards,
Niraj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
8 3469
Dear Experts, pls help, i searched the whole of MSDN and all possilbe
sites , but can't get a silution to this.

Thanks & Regards,
Niraj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #2
All MVPs, is there a solution to this... ?

Pls respond

Thanks & Regards,
Niraj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3
am following up desparetly cause this is a serious issue with ASP, is
there a way out .... ?

Thanks & Regards,
Niraj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
"Niraj Khandwala" <kn****@vsnl.net> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
All MVPs, is there a solution to this... ?

Pls respond

Thanks & Regards,
Niraj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


I'm no MVP but to answer your question, yes there is a solution to this. Now
all that's missing is what THIS is.
Jul 19 '05 #5
hi, Chris, thanks for the response.

i have a hughe file to upload,,,,, now i write a loop and within the
loop the records get uploaded, is there a way to trap the error and
thorw it as soon as the error occurs.

currently am using the "on Error Resume Next" and then at the end of the
page "if err.Number .... blah blah..."

also this condition if Err.Number etc has limited properties, as in it
does not show the line number column number etc ... like the
Server.GetLastError object
Thanks & Regards,
Niraj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #6
"Niraj Khandwala" <kn****@vsnl.net> wrote in message
news:ux**************@TK2MSFTNGP11.phx.gbl...
hi, Chris, thanks for the response.

i have a hughe file to upload,,,,, now i write a loop and within the
loop the records get uploaded, is there a way to trap the error and
thorw it as soon as the error occurs.

currently am using the "on Error Resume Next" and then at the end of the
page "if err.Number .... blah blah..."

also this condition if Err.Number etc has limited properties, as in it
does not show the line number column number etc ... like the
Server.GetLastError object


You could do it in JavaScript and use the try/catch construct. Or you can
put an error test immediately after each record upload in VBScript.
Something like

On Error Resume Next
'Do some stuff
'Start Loop
'Upload Record
If Err Then
'Do some error handling
End If
'End Loop

If you actually provide sample code, I could probably offer more than just
the "hand-waving" above. Also, could you specify database, version, DDL, and
sample data? Perhaps this could be done via a database utility like DTS for
SQL Server.
Jul 19 '05 #7
hey, Chris thanks,

here are the details
IIS5.0 , SQL Server 2000, No DLL used.

Sample code :
----------------------------------------
set oTs = oFs.OpenTextFile(strFileName)
con.BeginTrans
On Error resume next
do while oTs.AtEndOfStream = False
strLine = oTs.ReadLine
strArray = split(strLine,"|")
if ubound(strArray) > 0 then

rst("txt_idcode") = ltrim(strArray(0))
rst("nbr_micr") = strarray(1)
rst("amt_chkamt") = cdbl(strarray(2))
rst("cod_state") = ltrim(strarray(3))
blah blah ...
Loop

if Err.number <> 0
do error handling and roll back. but this does not show proper errors /
line number / column number and ADODB errors do not even redirect to my
custom error page :(
end if

__________________
Thanks & Regards,
Niraj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #8
"Niraj Khandwala" <kn****@vsnl.net> wrote in message
news:uu**************@TK2MSFTNGP12.phx.gbl...
hey, Chris thanks,

here are the details
IIS5.0 , SQL Server 2000, No DLL used.

Sample code :
----------------------------------------
set oTs = oFs.OpenTextFile(strFileName)
con.BeginTrans
On Error resume next
do while oTs.AtEndOfStream = False
strLine = oTs.ReadLine
strArray = split(strLine,"|")
if ubound(strArray) > 0 then

rst("txt_idcode") = ltrim(strArray(0))
rst("nbr_micr") = strarray(1)
rst("amt_chkamt") = cdbl(strarray(2))
rst("cod_state") = ltrim(strarray(3))
blah blah ...
Loop

if Err.number <> 0
do error handling and roll back. but this does not show proper errors /
line number / column number and ADODB errors do not even redirect to my
custom error page :(
end if


1. DLL stands for Data Definition Language or Data Declaration Language
depending on who you talk to. Regardless, it boils down to providing the
CREATE TABLE, CREATE INDEX, etc.. statements necessary to reproduce your
environment. That coupled with some sample data allows us to provide a
concrete solution instead of having to guess at what "blah blah..." means.
Here's an article:

http://aspfaq.com/etiquette.asp?id=5006
2. I'm assuming the rst is a ADODB.Recordset object. If so, you shouldn't be
using a recordset to perform DML (Data Manipulation Language such as INSERT,
UPDATE and DELETE). Use the Execute method of the connection object or the
"procedure-as-method" option. Here's another article:

http://aspfaq.com/show.asp?id=2191
3. This is almost certainly something that should be done with DTS (Data
Transformation Services) or BCP (Bulk Copy) is SQL Server. Please read the
related sections in BOL (Books Online).
4. If after all this you are still hell-bent on using this approach you will
need to inspect the ADODB.Connection.Errors collection instead of the Err
object. You will also need to define variables for current row and column as
you iterate through the source data. After each line that could possibly
generate an error, you will need to check the ADODB>Connection.Errors
collection and branch accordingly. As for transactions, I'm not sure DML via
a ADODB.Recordset object can participate in one. Another reason to rethink
the insert-via-recordset approach.

Sorry I couldn't be more help.
Jul 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Christian Christmann | last post: by
13 posts views Thread by Thelma Lubkin | last post: by
3 posts views Thread by Stefan Johansson | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.