ASP Error Handling

N

Niraj Khandwala

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
 
N

Niraj Khandwala

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
 
N

Niraj Khandwala

All MVPs, is there a solution to this... ?

Pls respond

Thanks & Regards,
Niraj
 
N

Niraj Khandwala

am following up desparetly cause this is a serious issue with ASP, is
there a way out .... ?

Thanks & Regards,
Niraj
 
C

Chris Hohmann

Niraj Khandwala said:
All MVPs, is there a solution to this... ?

Pls respond

Thanks & Regards,
Niraj

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.
 
N

Niraj Khandwala

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
 
C

Chris Hohmann

Niraj Khandwala said:
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.
 
N

Niraj Khandwala

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
 
C

Chris Hohmann

Niraj Khandwala said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top