Without knowing which exact line the error occurs on, we can't help you with a specific answer.
The best (indeed pretty much only) solution is to use the debugger.
Put a breakpoint on the first line in the method:
DataTable dailyattendance = new DataTable();
And single step though it.
You can examine each variable at each step and decide what should happen, then compare that with what did happen when you actually run the line.
Only then will you have anywhere near enough information to start solving this!