PDA

View Full Version : connection error object


charon
05-05-2003, 12:48 PM
hi,
I just wondering why my error message won't be displayed, instead i get error from server:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Microsoft Access Driver] Could not find output table 'deatilList.

Below is my code:

cSQL = "CREATE TABLE MyData (Name VARCHAR(20), Sex VARCHAR(20), Application VARCHAR(20), Status VARCHAR(20))"
cSQL2= "INSERT INTO detailList (DID, JobID, CourseID) VALUES ('" & DID & "','" & JOBID & "','" & COURSEID & "')"
objDC.BeginTrans
objDC.Execute(cSQL)
objDC.Execute(cSQL2)
If objDC.Errors.Count > 0 Then
objDC.RollbackTrans
For each myError in myError.Errors
If myError.Number <> 0 Then
eStr = "<table border=1 width=""90%"" align=""center""" & _
" bordercolor=""#E2EAEE""" & _
" style=""font-family:verdana; font-size:8pt;"" cellpadding=3>" & _
"<tr><td width=100>Error Property</td><td>Contents</td>" & _
"</tr><tr><td>Number</td><td>" & myError.Number & _
"</td></tr><tr><td>Native Error</td><td>" & _
myError.NativeError & "</td></tr>" & _
"<tr><td>SQLState</td><td>" & myError.SQLState & _
"</td></tr><tr><td>Source</td><td>" & _
myError.Source & "</td></tr>" & _
"<tr><td valign=""top"">Description</td><td>" & _
myError.Description & "</td></tr>" & _
"<tr><td>Page</td><td>" & Request.ServerVariables("SCRIPT_NAME") & _
"</td></tr><tr><td>Date & Time</td><td>" & _
FormatDateTime(Date, 1) & " " & Time & _
"</td></tr></table><br>"
End If
Next


Else
objDC.CommitTrans
msg = "The table for " tablename & " has been created"
End If

I purposely rename the detailList table to DetailList2, generate error, force my error message to display. But cannot, instead error from server as mentioned aboved.

Pls advice!

arnyinc
05-05-2003, 03:56 PM
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Microsoft Access Driver] Could not find output table 'deatilList.'

The error you pasted has a typo in it (the a and t are reversed in detail). Does this typo show up somewhere else in your code?

charon
05-06-2003, 03:21 AM
it is just typo error. nothing to do with why my error message wont be displayed

arnyinc
05-06-2003, 01:49 PM
Are you getting a new error now, or is everything working?

Roy Sinclair
05-06-2003, 04:32 PM
The reason you get the MS generated error is because you didn't turn on error checking in your code ("On Error Resume Next"), therefore any errors result in the termination of your code and the server outputing it's own error instead.

charon
05-07-2003, 02:47 AM
oh..i see, thanks roy, will try and see.....

charon
05-07-2003, 05:10 AM
Hi, Roy
Until before I read your message, I was confused between Conention Object's error object
and ASP Error handler. I thought we can just use the Connection Object's Error Object without using the
On Error Resume Next.
Now I 100% understand what is going on. I feel extremely happy. Below is my explaination on my previous code:
Correct me if I'm wrong.

1.) If without stated the On Error Resume Next, once the an error occured at
cSQL2= "INSERT INTO detailList (DID, JobID, CourseID) VALUES ('" & DID & "','" & JOBID & "','" & COURSEID & "')"
It will stop from executing, so it won't go to :
If objDC.Errors.Count > 0 Then
objDC.RollbackTrans
For each myError in myError.Errors
If myError.Number <> 0 Then
eStr = "<table border=1 width=""90%"" align=""center""" & _
------

That is why the error message eStr won't be displayed.

Correct on not?????:))

2.) But I still confused the On error Resume Next in and out of the function/procedure which I have posted my message here with title On error resume next.

Roy Sinclair
05-07-2003, 03:47 PM
Correct.

charon
05-10-2003, 05:53 AM
1.) just would like to know, by putting one on error resume next on top of ASP page is the same as put more than on error resume next statement right?? as below:


on error resume next
-
-
-
on error resume next
-
-
-
-
If err.Number <> 0 then
End if



on error resume next
If err.Number <> 0 then
End if



2.)Since by putting the On Error Resume Next in The ASP PAGE which call the function already be able to catch the error, why we still need to put it inside the function.

due to no response frm my post, so try here...

Roy Sinclair
05-12-2003, 02:47 PM
Putting "on error resume next" at the top of the program is a bad idea. Most of the time an unexpected error should cause your program to crash, use this error checking to catch the "expected" errors and turn it back off right afterwards.