I created a batch class for the data import from SQL and ran it. The class works correctly the first time it runs, but it doesn't update when I set recurrence and delete/add records. The code goes from 215 to 237 and from there to 243 and makes an insert, but when Recurrence works, it comes to 215 and goes from there to 237 and then to 238 and does not enter the insert. how can I figure this out?
It seems that a CLR exception gets thrown at line 237, which you don't catch. That's why the next line isn't reached. The data is already committed at that point.
I also see logical errors in your code. You dispose the reader at lines 205 and 220, but you don't break the execution, therefore line 210 will try to call Read() on already disposed reader. I assume you actually meant throwing an error, not just adding a message to infolog. Therefore you should use throw error(...) instead of mere error(...). If you agree, then you don't need the catch block inside the loop. Also, your catch block can be greatly simplified and you can put the common logic to finally. For example:
System.Exception ex; try { while (reader.Read()) { ... } } catch (ex) { throw error(strFmt(..., ex.Message)); } finally { if (reader) { reader.Dispose(); } }
If would have adjusted your code if you provided it as text and not as a screenshot.