473,412 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Bypassing a database connection

Hi

I have a bit of code which executes an SQL statement.on my webpage. If the
execution fails i do not want a standard error coming up that asp normally
shows - instead i would like something like

if (cnn.execute) = failed Then
'Do This
End If
Jul 19 '05 #1
4 1260
Andy Lee wrote on 24 jun 2004 in
microsoft.public.inetserver.asp.general:
I have a bit of code which executes an SQL statement.on my webpage.
If the execution fails i do not want a standard error coming up that
asp normally shows - instead i would like something like

if (cnn.execute) = failed Then
'Do This
End If


<%
on error resume next
set CONNECT = server.CreateObject("ADODB.Connection")
CONNECT.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &_
Server.MapPath("notexisting.mdb") & ";"

if err.number <> 0 then
response.write "Database NOT found"
else
response.write "Database found"
end if
on error goto 0
%>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2
Evertjan. wrote on 24 jun 2004 in
microsoft.public.inetserver.asp.general:
Andy Lee wrote on 24 jun 2004 in
microsoft.public.inetserver.asp.general:
I have a bit of code which executes an SQL statement.on my webpage.
If the execution fails i do not want a standard error coming up that
asp normally shows - instead i would like something like

if (cnn.execute) = failed Then
'Do This
End If


<%
on error resume next
set CONNECT = server.CreateObject("ADODB.Connection")
CONNECT.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &_
Server.MapPath("notexisting.mdb") & ";"

if err.number <> 0 then
response.write "Database NOT found"
else
response.write "Database found"
end if
on error goto 0
%>


I now see you want to forgo a sql fault, [which is clearly your own
mistake]

Just try the same error trapping ?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3
My personal preference would be rather to create a custom error page :
http://support.microsoft.com/default...b;EN-US;224070

You could send a mail with error details and behave differently on your
development server.

IMO the key advantage is that you won't trap the same way things you are not
prepared for (for example the code below will show always a "database not
found" even if the problem is somewhere else in the connection string).

To trap for this specific error I would just test the file existance (using
Scripting.FileSystemObject) though this is IMO useless if you can't do
anything about it.

In short I would say :
- have a "catch all" page that display a generic message and mail details
- if you can do something when a particular condition is encoutered, handle
this at the code level (preferably byt testing before the error arise ie.
testing the file existance rather than trapping an error becuase the file is
not found etc...)

Patrice

--

"Evertjan." <ex**************@interxnl.net> a écrit dans le message de
news:Xn********************@194.109.133.29...
Andy Lee wrote on 24 jun 2004 in
microsoft.public.inetserver.asp.general:
I have a bit of code which executes an SQL statement.on my webpage.
If the execution fails i do not want a standard error coming up that
asp normally shows - instead i would like something like

if (cnn.execute) = failed Then
'Do This
End If


<%
on error resume next
set CONNECT = server.CreateObject("ADODB.Connection")
CONNECT.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &_
Server.MapPath("notexisting.mdb") & ";"

if err.number <> 0 then
response.write "Database NOT found"
else
response.write "Database found"
end if
on error goto 0
%>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #4
Patrice wrote on 24 jun 2004 in microsoft.public.inetserver.asp.general:
My personal preference would be rather to create a custom error page :
http://support.microsoft.com/default...b;EN-US;224070


[please do not toppost on usenet]

This is not possible for the many of us that rent a virtual server.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jens Kalkbrenner | last post by:
MS SQL-Server 7.0 Bypassing recovery for database 'EfW_765' because it is marked IN LOAD. What does this mean? Our customer is backing up is maindatabase and is recovering it to this database for...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
4
by: antonyliu2002 | last post by:
Let me try to make clear what my concern is. I think it is a pretty interesting one, which I think of while I am developing my web application. I have an authenticated/authorized web...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
1
by: jdorp | last post by:
I read KP article at support.microsoft.com (Q177594) that stated that with the following code: Sub Command1_Click() Dim db1 As Database Dim db2 As Database Dim rs As Recordset Dim strConnect...
1
by: =?Utf-8?B?QXVzdGluIFN0ZXBoZW5z?= | last post by:
In my commercial financial application I run a deposit report. I use an option to copy the report to the Clipboard. I then run a .NET consol app to “grab” the Clipboard and format the data...
4
Chrisjc
by: Chrisjc | last post by:
The question at hand is I bypass an array in column 4... but I also have something else that should be going in there from the database but because I am bypassing it and forcing it to show the ony...
1
Curtis Rutland
by: Curtis Rutland | last post by:
How To Use A Database In Your Program Part II This article is intended to extend Frinny’s excellent article: How to Use a Database in Your Program. Frinny’s article defines the basic concepts...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.