Hey there,
You need to check whether the
DataSet
contains anything before using it.
In your case the
DataSet
ds is probably null, which is causing the Exception.
Wrap:
if (i < ds.Tables[0].Rows.Count - 1){
in
if(ds != null && ds.Tables[0].Count > 0){}
You'll need to do the same in other places in your code as where there is a chance of DataSet being null.
It seems you haven't really created the object of
DataSet ds;
in your code. So, Make sure you fill it before you can use it.
Let me know if it helps.
Azee...