I have a loop that includes a try/catch. The loop is checking if a DB insert succeeded or failed. What happens is that if the first INSERT succeeds, the catch does not execute (which is the expected behavior). The problem is that if any INSERT fails, the remaining INSERTS report failure because the catch error number from the failed INSERT is not clearing at each loop. So, potentially, the next INSERT following a failed INSERT could have succeeded, but the report signifies it has failed. Confusing?

http://www.c1.cc/v2/recipient_mgr.asp

First, submit the form as it is. You will see 5 failures, because the 5 records already exist in the DB. Then, go back to the form and change one or two form fields in the middle. See what happens.

Code:
<% if (Request.querystring("s") != "") {
	RSQL = "SELECT * FROM Recipients"
	var R = Server.CreateObject("ADODB.Recordset");
    R.Open(RSQL, Conn, 3, 3);
	
	counter = 0;
	var e = new Enumerator(Request.Form)
	while (!e.atEnd(e)) {
		try {
			x = 0;
			counter++
			i = e.item()
			if (i.replace("_" + counter,"") == "EmailAddress") {
				R.AddNew
				R("RecipientEmailAddress") = Request.Form(i)
				R.Update
			}
		} catch(theError) {
			x = theError.number
		}
		
		if (x != 0) {
			Response.Write(counter + ". " + "FAILURE<br>");
		} else {
			Response.Write(counter + ". " + "SUCCESS<br>");
		}
		e.moveNext()
	}
}
%>