I am newbie to c#. I working on a project. I am trying to loop thru a dataTable containing about 100,000 rows. I am using index as varibale to access the rows of dataTable like following.
for(int index=0; index< DT.rows.count;index++)
string member ="";
member = DT.Rows[index]["memberName"];
After running 32768 it is showing error as There is no row at postion at -32768. I am thinking that this is becuase of DataTable Row index accepts only integer value as index and it's value is more than 32678 it is showing error. Can anybody tell me how to get rid of this???
Thanks in advance.
hi this is only because range of integer i.e int16 datatype is -32768 to 32767 so after looping 32767 times it jumps into negative side and this cycle repeats.
So to avoid this use long datatype or you can also go with simply int.
i'll suggest you to write (DT.rows.count - 1) as index stars from zero this may also cause bug
accept solution if you have got the solution.
Edited 14-May-12 18:11pm
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)