QUERY: 'On Error Resume Next' Scope Rules
This has been puzzling me for very long time and no where has
talked about the scope of a 'On Error Resume Next' statement.
When we program ASP(.NET) pages then we usually like to let
ASP(.NET) stop at errors and report back to us. However there
are parts of our scripts that we know an error will be thrown
and we encapsulate that area inbetween:
On Error Resume Next
Err.Clear
'Try block
If Err.Number Then
'Catch block
End If
On Error GoTo 0
This is similar to the infamous try {} catch(e) {} blocks in
Java/C++, etc.
If we forget the last line 'On Error GoTo 0' then our ASP(.NET)
scripts runs over all errors thrown and we find it hard to
find bugs. So the big question is, does 'On Error Resume Next'
go out of scope when it's written inside a block
(eg. Function)?
Function Function1()
On Error Resume Next
'Our code
End Function
When the Function1 call returns, does the outside calling scope
automatically stays as it was (On Error GoTo 0)?
View Replies
ADVERTISEMENT
I've a query on On Error Resume Next. I've explained what I understand for each case, I'm not sure that this is true.
Case:
1] Used in Function/Sub: will resume to the next statement in the
function or sub; but will not affect the error out side of the functions
2] Used at the top of the asp page: will affect all the page code and
will not affect the function/sub in the page at all.
3] Used in the page where ever required:?
View Replies
View Related
I put the On Error Resume Next command as the very first line in my ASP
pages, which may contain various inc files and sub-routines/functions, so
that I can try and stop the dreaded DB error messages displaying to visitors
and would-be hackers.My question is, does this one statement at the top of the page cater for all of the code that might be executed in the page, in the include files and in
sub-routines/functions or do I have to put the statement in certain places
as well?The reason I ask is that I'm sure if I get one of my include file names
wrong it brings up an error rather than going straight through and
displaying a funny page.I hope I don't have to put it in various places as I like to have this one statement so that I can flip back and forth between live and dev time and
having to go into 'x' amount of pages to flip between these 2 states would
be tiresome.
View Replies
View Related
My code works when the table is not found. But when the table is found it doesn't do the else part..Code:
Dim oConn
Dim oRs
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Store_Form"
Set oRs = Server.CreateObject("ADODB.Recordset" )
elseif campo = "txtAN_GEN" then
on error resume next
Set oRs = oConn.Execute("SELECT * FROM 00_MOD48")
If err <> 0 then 'If table not found
GetFieldValue = "00001"
else
GetFieldValue = "150"
end if
View Replies
View Related
I am using On Error Resume Next to allow my application to deal with errors accessing the database, i.e. if the DSN-less connection doesn't work then it tries the DSN connection and this is fine.
What I want to find out is how can i stop the rest of the page continuing after errors, in essence I want to cancel the On Error Resume Next statement after the database connection stuff is done so that errors will stop the page and I can debug them.
View Replies
View Related
I have a piece of code that i created. It actually works as it should. The only problem is the objrs2.update causes an error-duplicate primary key. However when i check the database it has done what it should.
I then tried to use on error resume next, but it keeps timing out and i do not want to extend the time limit. Does someone know how to get round this? Code:
View Replies
View Related
Is there a way to avoid On Error Resume Next for:
cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)
'On error resume next
rs("email_address")
'// This record does not exist thus throwing up an error. I could use On
Error to resume and then do this
'// If rs.eof or rs.bof
'//
.....But I hate this convention as I find debugging a problem. Is there a
better way?
View Replies
View Related
I'm on the last piece of this project, when a user goes to this page "myfolder.asp" it shows the contents of their folder.
If they don't have one created yet, I want to give them a friendly message: "You have nothing in your folder!" , and continue with the rest of the HTML code, but then ignore the Repeat Regions and dynamic text thats inside the HTML.
Right now I have it woking if the table exists, it shows the records. If I delete the table, I have this message at the top of the screen and nothing else: "You have nothing in your folder!"
Here is the code:
View Replies
View Related
One thing I've started to notice lately is that asp seems to be very sensitive to how quotation marks are layered. Does anyone know where I can find out when to use double quotes and when to use single quotes? Code:
SelectSQLB = "SELECT * FROM TeamRosters WHERE IDNumber = Session(' 'TeamMember' & LoopCounter')"
Is the line that's giving me trouble and I'm not really sure how to layer it. Every logical combination I've tried has produced a different sort of error. Note that TeamMember# is a session variable and loopcounter is a local variable used to select which TeamMember# session variable to use. Before I've noticed that pretty much it works like this: " ' ' " but that was for two layers deep. What's the syntax for going three layers in?
View Replies
View Related
I created a ADODB.Connection object in Session On_Start and tried to connect to the databse On_Start. It is giving errors. Can't have a connection opened only once in a whole applicatio like VB.
The Con variable is available for the whole session but the connection state is not available for the whole session. Do I need to open a connection everytime I want to access a database????
View Replies
View Related
I have problem regarding cookies collection in response object. the senario is. I have created a cookie on signin page using:
Response.Cookies("username") = "userid"
If i print the value of cookie on this page then it shows me the correct value.
when i print the value of this cookie in another page using response.write request.cookies("username")
It doesnt print any value.
I have checked for every security problem in my internet browser but havent got any result. i am using internet explorer 6.
View Replies
View Related
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/changeprofile.asp, line 44
Code:
View Replies
View Related
I am working on a project using an access db. Here is the problem.
Error
Code:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
operator) in query expression 'unit=6400s'
Unit is what it is suppose to be, I don't understand why I am getting this error? Here's the code for this part.
Code:
sql="SELECT * FROM " & tableStr & " WHERE Model=" & unitStr
tableStr and unitStr are variables. Table and unit are passed into the page and are assigned to the two variables through a request.querystring().
View Replies
View Related
Basically, I have an asp application that uses a database connection,
and I want to declare (create) that connection in an include and use it
throughout the application in various functions. I've tried making the
connection object a public variable, a constant, making the functions
public, passing the connection object in byRef, byVal, etc... I just
can't get it to work. Is this not possible in classic ASP? Code:
View Replies
View Related
I am making a testing project to get my hands on ASP classic. I have a question about Global Scope Variables e.g in PHP we make a file where we define some values which are global, e.g site URL, site title etc, and then we can include that in any page to get that value.
I read Global.asa works very good in fact we dont need to include that in every page to use stuff within this file. I read some examples but they are mostly about functions in this file. Can anybody guide me please how to define variables in Global.asa to use them sitewise?
View Replies
View Related
There are many web sites on the server - each has a virtual directory pointer to a common directory containing frequently used routines. Scripts run from the virtual directory appear to have no access to session (or application) variables. Is this expected behaviour? Or have I yet to track down a bug?
View Replies
View Related
Can ASP resume download/ upload when uploading large files using ASP, like Download programs do? If so, can anybody point me to tutorial or a script I can start with?
View Replies
View Related
Does anyone know of a way to enumerate the local variable scope? The
reason I ask is that I have a function that dumps the contents of
response,request,server,etc... for debugging purposes. I'd like to also
display the local variables.
View Replies
View Related
I have a piece of vbscript that returns the user logged on to the machine. it is as follows:
<script language="vbscript">
Set WshNetwork = createObject("WScript.Network")
stringUser = (WshNetwork.userName) 'store username in variable stringUser
document.write("Username: " & stringUser) 'output value to web page
</script>
Now I need to use the value of stringUser on other pages of my asp application for database queries, form values etc. I have tried to call stringUser from inside <%..........%>, but it doesn't recognize the variable. Everytime I try to output the value from wthin asp code, it just appears as blank space. Any ideas?
View Replies
View Related
How can I give a user-defined object session scope? From
http://www.microsoft.com/windows200...asp/iiwaobu.htm
I gather that it can be done, but there are no examples. Simply setting
Set Session("tag") = new MyClass
doesn't work.
View Replies
View Related
i need 2 files html as well as asp forms. pls help me with working code.
View Replies
View Related
query="select * from mytable where id="&xx
id is a numerical field..
if a user choose xx char or a string my query gives an error in asp...
i tried
if err.number <>0 then response.redirect "xx.asp"
but problem is still continueing
View Replies
View Related
This is my SQL Query, but I get the error message:
Item cannot be found in the collection corresponding to the requested name or ordinal.
/spmanagerdownload/downloadadmin.asp, line 444
Code:
View Replies
View Related
I am trying to run an SQL SELECT query, however, I am experiencing some problems with it.
It is coming up with the error; " Microsoft VBScript compilation error '800a0401'
Expected end of statement "
It is pointing to line 46 which is highlight in bold within my code below; is the error coming up because of the way I have formatted the query?
strSQL = "SELECT * FROM tbl_lunch WHERE (((tbl_lunch.Type)="general")) ORDER BY tbl_lunch.Type;"
Thanks for any help you may be able to give me on this
View Replies
View Related
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/SHOP/add_emp_result.asp, line 41
how can i slove this problem?
View Replies
View Related
<%
sqlQuery = "INSERT INTO contacts (firstname, lastname, email, department) VALUES (" & contact_first & ", " & contact_last & ", " & contact_email & ", " & contact_department & ")"
connect.Execute sqlQuery
%>
The error I'm getting is
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/ebusiness0405asp/greg/asp/project/adminContactAdded.asp, line 57
Line 57: connect.Execute sqlQuery
Ideas?
View Replies
View Related
I need help on this error that occured on one of the pages. fuunny thing that its happen in localhost and not in the web server. below is the code and the highlight of where error occured.The error mentioned in the page is :
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
/shop/confirmation21.asp, line 245 . can anyone kind enuff to let me know whats it about?
Code:
View Replies
View Related
I am trying to use a query to filter SQL Server 2000 records by a date
value.
Here is relevant columns in my database table (tblContent):
title [nvarchar]
starting [smalldatetime]
.... and here is my query:
Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"
I've done exactly this query on numberous occassions in the past with no
problems at all but this time I get the following error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of char data
type to smalldatetime data type resulted in an out-of-range smalldatetime
value.
What on earth is going on? I'm not using a char data type anywhere! I am
doing all the initial development locally and I have just installed XP
Service Pack 2. I realise it's unlikely, but that's the only thing I can
possibly attribute it to. Or am I just missing something obvious?
View Replies
View Related
Please look over this code and tell me why I keep getting this 'Number of query values and destination fields are not the same.' error.
Set rowcreation=connectionToDatabase.Execute("INSERT INTO hotlines(user_ip,date_time_opened) VALUES('" & user_ip & "," & date_time_opened & "')")
View Replies
View Related
i'm trying to make a form that will pull details from a record that is found with (asset Number) but comes up with this error: 2342 "A RunSQL action requires an argument consisting of an SQL Statement"
Dim SQL As String
SQL = "SELECT *"
SQL = SQL + " FROM Computer"
SQL = SQL + " WHERE (((Computer.Asset)=" & TxtAsset.Value & "));"
DoCmd.RunSQL SQL
View Replies
View Related
Does anybody know what this error is about?
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable
query.
/app/admin/admin.asp, line 201
View Replies
View Related
this runs perfectly as a .vbs but I'd like to convert it to an ASP... any
ideas? Code:
View Replies
View Related
I have created a query and everytime I try to run it I get this error:
Microsoft JET Database Engine error '80004005'
Record is deleted.
/vsadmin/inc/incsearch.asp, line 162
This is the query: Code:
View Replies
View Related