ASP Error Handling

Discussion in 'ASP General' started by Niraj Khandwala, Jul 20, 2004.

  1. 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!
    Niraj Khandwala, Jul 20, 2004
    #1
    1. Advertising

  2. 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!
    Niraj Khandwala, Jul 21, 2004
    #2
    1. Advertising

  3. 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!
    Niraj Khandwala, Jul 27, 2004
    #3
  4. 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!
    Niraj Khandwala, Jul 30, 2004
    #4
  5. "Niraj Khandwala" <> wrote in message
    news:...
    > 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.
    Chris Hohmann, Jul 30, 2004
    #5
  6. 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!
    Niraj Khandwala, Jul 31, 2004
    #6
  7. "Niraj Khandwala" <> wrote in message
    news:...
    > 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.
    Chris Hohmann, Aug 2, 2004
    #7
  8. 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!
    Niraj Khandwala, Aug 2, 2004
    #8
  9. "Niraj Khandwala" <> wrote in message
    news:...
    > 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.
    Chris Hohmann, Aug 2, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. basha
    Replies:
    1
    Views:
    345
    Christopher Kimbell
    Nov 2, 2003
  2. Replies:
    2
    Views:
    361
  3. Mark Tarver
    Replies:
    22
    Views:
    1,280
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,919
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    176
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page