I am developing a file parser in C# such that I have a file with many many rows. I want to write that to database.
I have created a loop in which I read the file and issue an insert.
However, what I would like to do is read say 100 rows then commit all 100, then read the next 100 and commit them and so on an so forth.
My problem (a bit conceptual) is how to find out the last set of rows as that could be less than 100.
For e.g. if my file has 550 rows, I can read 5 chunks of 100 and commit them using modulus operator on the line counter but what happens to the last batch of 50?
Any ideas in this area will be highly appreciated.
Thanks.