Need to trap a database error in server-side asp 
Author Message
 Need to trap a database error in server-side asp

Hey all,

I'm opening an ADO connection object pointed at a SQL 7 database using user
supplied username/password. If the username/password is incorrect then it
just returns the error message to the user. I would like to trap the error
and handle it more gracefully but I haven't been able to figure out how to
do it. I'm pretty fluent with SQL Server, VB, ADO and what-not but I'm
stilll kinda new to ASP and VBScript. Any help would be appreciated.

Thanks,
Chris Lande
Software Developer
Pyromation, Inc.



Sun, 27 Oct 2002 03:00:00 GMT  
 Need to trap a database error in server-side asp
Here's the code I use to trap Oracle errors in vbscript. Basically, you
turn on error handling with "on error resume next" and then put your
trapping code immediately after the database query or event, where
processing is resumed if there is an error.
Afterwards, you can turn off error handling with "on error goto 0"

        on error resume next
        err.clear
        conn.begintrans
                'record does not exist. Use insert statement
        sql = "insert into person (first_name,                     " & _
        (insert statement text)
        "person_nbr_seq.nextval )"
        conn.execute sql, recordsaffected
        if err.number<>0 then
                err_code = -1
                msg = "A database error occurred. Record not inserted."
                conn.rollbacktrans
                on error goto 0   ' turn off error handling
                exit function
        end if



Quote:
> Hey all,

> I'm opening an ADO connection object pointed at a SQL 7 database
using user
> supplied username/password. If the username/password is incorrect
then it
> just returns the error message to the user. I would like to trap the
error
> and handle it more gracefully but I haven't been able to figure out
how to
> do it. I'm pretty fluent with SQL Server, VB, ADO and what-not but I'm
> stilll kinda new to ASP and VBScript. Any help would be appreciated.

> Thanks,
> Chris Lande
> Software Developer
> Pyromation, Inc.

--
Erik Slotboom

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 27 Oct 2002 03:00:00 GMT  
 Need to trap a database error in server-side asp
Just use for that a SQL Server 7 Stored Procedure! Its just es easy, you
only need the ADO.Command Object and some Parameters!

To handle it through ASP, you can handle the error, or indeed with
sql7performance in background, you can count the records with that name =
and pass =. (like select count(userid) where name="kj" and pass="sd") and
when it returns 0 you need nothing more to do.

i dont have an ASP script for handling ado errors at hand... but somewhere i
used it...

Greetings



Quote:
> Hey all,

> I'm opening an ADO connection object pointed at a SQL 7 database using
user
> supplied username/password. If the username/password is incorrect then it
> just returns the error message to the user. I would like to trap the error
> and handle it more gracefully but I haven't been able to figure out how to
> do it. I'm pretty fluent with SQL Server, VB, ADO and what-not but I'm
> stilll kinda new to ASP and VBScript. Any help would be appreciated.

> Thanks,
> Chris Lande
> Software Developer
> Pyromation, Inc.



Sun, 27 Oct 2002 03:00:00 GMT  
 Need to trap a database error in server-side asp
Hi

Since you get the error only if user not present in the DB
you should be able to fix that by checking for rs.EOF

--
Best Regards
   Vidar Petursson -  MVP
http://www.icysoft.com


No matter where you go there you are.
-

Quote:
> Hey all,

> I'm opening an ADO connection object pointed at a SQL 7 database using
user
> supplied username/password. If the username/password is incorrect then it
> just returns the error message to the user. I would like to trap the error
> and handle it more gracefully but I haven't been able to figure out how to
> do it. I'm pretty fluent with SQL Server, VB, ADO and what-not but I'm
> stilll kinda new to ASP and VBScript. Any help would be appreciated.

> Thanks,
> Chris Lande
> Software Developer
> Pyromation, Inc.



Sun, 27 Oct 2002 03:00:00 GMT  
 Need to trap a database error in server-side asp
oh, it tested it... that works! damn you're good :)

---
set rstemp = conn.execute
if rstemp.eof then
 end
else
...
---

Greetings



Quote:
> Hi

> Since you get the error only if user not present in the DB
> you should be able to fix that by checking for rs.EOF

> --
> Best Regards
>    Vidar Petursson -  MVP
> http://www.icysoft.com


> No matter where you go there you are.
> -


> > Hey all,

> > I'm opening an ADO connection object pointed at a SQL 7 database using
> user
> > supplied username/password. If the username/password is incorrect then
it
> > just returns the error message to the user. I would like to trap the
error
> > and handle it more gracefully but I haven't been able to figure out how
to
> > do it. I'm pretty fluent with SQL Server, VB, ADO and what-not but I'm
> > stilll kinda new to ASP and VBScript. Any help would be appreciated.

> > Thanks,
> > Chris Lande
> > Software Developer
> > Pyromation, Inc.



Sun, 27 Oct 2002 03:00:00 GMT  
 Need to trap a database error in server-side asp
vbscript doesn't have decent error handling.

from asp, you are probably limited to something like this:

the line before your error occurs add an On Error Resume Next statement.
the line immediately after, test to see if there was an error using
Err.Number.
if the error code is to do with your security problem, branch off and deal
with it etc

from experience, i recommend then putting an On Error Goto 0 after this
routine (On Error Resume Next is dangerous!)

hope this helps

cheers

jon


Quote:
> Hey all,

> I'm opening an ADO connection object pointed at a SQL 7 database using
user
> supplied username/password. If the username/password is incorrect then it
> just returns the error message to the user. I would like to trap the error
> and handle it more gracefully but I haven't been able to figure out how to
> do it. I'm pretty fluent with SQL Server, VB, ADO and what-not but I'm
> stilll kinda new to ASP and VBScript. Any help would be appreciated.

> Thanks,
> Chris Lande
> Software Developer
> Pyromation, Inc.



Sun, 27 Oct 2002 03:00:00 GMT  
 Need to trap a database error in server-side asp
Hi

JScript has a good error handling

try
   {
    conn.Execute("SOMESTUFF");
    }
    catch(e)
            {
             Response.Write("Error: " + e.description);
            }

MS Scripting site:
http://msdn.microsoft.com/scripting

--
Best Regards
 Vidar Petursson Microsoft MVP
==========================
http://www.icysoft.com
http://www.dna.is



==========================
No matter where you go there you are
-

Quote:
> oh, it tested it... that works! damn you're good :)

> ---
> set rstemp = conn.execute
> if rstemp.eof then
>  end
> else
> ...
> ---

> Greetings



> > Hi

> > Since you get the error only if user not present in the DB
> > you should be able to fix that by checking for rs.EOF

> > --
> > Best Regards
> >    Vidar Petursson -  MVP
> > http://www.icysoft.com


> > No matter where you go there you are.
> > -


> > > Hey all,

> > > I'm opening an ADO connection object pointed at a SQL 7 database using
> > user
> > > supplied username/password. If the username/password is incorrect then
> it
> > > just returns the error message to the user. I would like to trap the
> error
> > > and handle it more gracefully but I haven't been able to figure out
how
> to
> > > do it. I'm pretty fluent with SQL Server, VB, ADO and what-not but I'm
> > > stilll kinda new to ASP and VBScript. Any help would be appreciated.

> > > Thanks,
> > > Chris Lande
> > > Software Developer
> > > Pyromation, Inc.



Mon, 28 Oct 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Need to trap a database error in server-side asp

2. ASP referring to server side variables in client side script

3. error handling for ASP server side components

4. Security with IIS, ASP, VB server side objects and SQL Server

5. Trapping Events - Server-Side Scipt Conflict

6. catching server-side ASP errors with catch?

7. Instancing Java-components from ASP with server-side JScript: ASP115 error

8. Server Side Scripter needs help on Client Side

9. Client Side question: Trap Scripting Errors

10. Client-Side vs Server-side ASP/JScript

11. OCX,ASP not showing from clients only from Server side

12. Use ASP to run server-side VB .exe

 

 
Powered by phpBB® Forum Software