sneakyimp
08-15-2004, 12:59 AM
ok i know it says "on an error go to the next statement" but my script is behaving all wacko. it would seem that the entire rest of the subroutine is skipped. i know the database execute is causing an error here...i don't know why the script continues running but only OUTSIDE this subroutine:
Sub SaveEntry
'on error resume next
sql="INSERT INTO MailingList (Name,Email,DateAdded,Age,ZipCode,Country,Gender,HeardAbout) VALUES "
sql=sql & "('" & gName & "','" & gEmail & "',#" & Now() & "#,'" & gAge & "','" & gZipCode & "','" & gCountry & "','" & gGender & "','" & gHeardAbout & "')"
Response.Write "we're saving...sql:" & sql & "<BR>"
set conn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("data/lustra.mdb")
conn.Open
Result = conn.Execute(sql,numRecordsAffected)
Response.Write "numRecordsAffected:" + numRecordsAffected
Response.Write "error:" + Err.Number
if Err <> 0 then
ErrMsg = "An error occurred: " & err.description
Elseif IsNull(numRecordsAffected) = "" then
ErrMsg = "FAILED. Your information was not saved. no records were affected."
%>
Your name has been entered!
</body></html>
<%
Response.End()
end if
conn.Close
End Sub
Sub SaveEntry
'on error resume next
sql="INSERT INTO MailingList (Name,Email,DateAdded,Age,ZipCode,Country,Gender,HeardAbout) VALUES "
sql=sql & "('" & gName & "','" & gEmail & "',#" & Now() & "#,'" & gAge & "','" & gZipCode & "','" & gCountry & "','" & gGender & "','" & gHeardAbout & "')"
Response.Write "we're saving...sql:" & sql & "<BR>"
set conn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("data/lustra.mdb")
conn.Open
Result = conn.Execute(sql,numRecordsAffected)
Response.Write "numRecordsAffected:" + numRecordsAffected
Response.Write "error:" + Err.Number
if Err <> 0 then
ErrMsg = "An error occurred: " & err.description
Elseif IsNull(numRecordsAffected) = "" then
ErrMsg = "FAILED. Your information was not saved. no records were affected."
%>
Your name has been entered!
</body></html>
<%
Response.End()
end if
conn.Close
End Sub