Re: ASP Error Handling

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Chris Hohmann (nospam_at_thankyou.com)
Date: 08/02/04


Date: Mon, 2 Aug 2004 13:10:36 -0700


"Niraj Khandwala" <kniraj@vsnl.net> wrote in message
news:uukT5yIeEHA.1000@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.



Relevant Pages

  • Re: What to learn?
    ... > Algorithms book would even remotely resemble his sample code, ... > apply to writing the sample code in the language of tomorrow's day? ... something *I* would like better than either of these (Cormen, Sedgewick). ...
    (comp.lang.cpp)
  • Re: A Turk to Rival Le Petomane! (corrected from "Pedomane")
    ... >>| language because their vocal tracts, yadda, yadda, ... blah blah blah and so on. ... >>| again, no, I am not joking. ...
    (sci.lang)
  • Re: Object of class Person could not be converted to string
    ... The job of the language designer is to provide clean and consistent mechanism for generating any possible expression, including "useless" ones. ... alert(new Blah()) - works in javascript ... Comparing programming languages and technologies is always productive, there's always something to learn from each other. ...
    (comp.lang.php)
  • Re: Object of class Person could not be converted to string
    ... echo fopen; - works ... alert(new Blah()) - works in javascript ... there's a difference between 'useless' and 'forbidden'. ... I'm just looking for the reason why it was taken out of the language. ...
    (comp.lang.php)
  • Re: Understanding # and function variables
    ... > best understood precisely as abstractions. ... If you try to think of one language in another language's ... the naive implementation in CL syntax, rather than C or something, I'm fine ... blah, blah, blah, that would help. ...
    (comp.lang.lisp)