Hi,

I have this sort of problem whenever the datatable has an empty cell,
it shows cannot find column 6 or depending on the number of the datatable column cell.

Why does this happen and how can I resolve this?

Thanks

This happens because the cell it is looking to get a value out of does not exist. Nothing was extracted from the database (or whatever the population method was) and so it crashes when it hits the null value.
You can either use defaults in your database to remove the null instances (meaning every record has some form of data in it) or add error checking in your code that can recover from trying to access a null object.
If an entire column is missing you may not have limited your search criteria or loop length to the number of columns in the data table. This is most commonly done by forgetting that the lengths of these objects are zero based and so if there are 5 columns in the data table your loop should run from 0 to 4, not 5.

This happens because the cell it is looking to get a value out of does not exist. Nothing was extracted from the database (or whatever the population method was) and so it crashes when it hits the null value.
You can either use defaults in your database to remove the null instances (meaning every record has some form of data in it) or add error checking in your code that can recover from trying to access a null object.
If an entire column is missing you may not have limited your search criteria or loop length to the number of columns in the data table. This is most commonly done by forgetting that the lengths of these objects are zero based and so if there are 5 columns in the data table your loop should run from 0 to 4, not 5.

Okay, already solved my problem, thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.