1.) You didn't get error at catch. It happened much before that and was handled by catch block.
2.) It could be any where in the code. It's difficult for us to pin point where it could be. It could as early as in first statement:
ds.Tables[0];
where the ds could be null. To prevent that, you should also check if the object is not null like this:
DataTable dt;
if(ds != null)
{
if(ds.Tables.count > 0)
{
dt = ds.Tables[0];
}
}
3.) Use Visual Studio to debug the code, and you would know where the error occured. Look at the great article from Abhijit Jana here:
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]