Chances are that something to do with your request is failing and that is throwing an exception that is being caught elsewhere.
Change the line to this:
rowsAffected = SQLcm.ExecuteNonQuery();
And add this line at the top of the method:
int rowsAffected = -1;
Now encase that code in a
try...catch
block and add breakpoints on the ExecuteNonQuery line, and inside the
catch
block.
Run your code again inside the debugger (you can remove the MessageBoxes for this) and watch what happens. When you run the
ExecuteNonQuery
statement, one of two things will happen. The first is that control will move to the
catch
block, and you can look at the exception detail to see why. The other is that
rowsAffected
will get set to the number of rows inserted. If that's 1, then fine. If not ... well, the catch block should have caught it!
Try that, and see what you find.