Hi,
To my knowledge what I understood is that the query doesnt return any data then the dataset ds will contain no table. Then in that case if you are trying to assign ds.Tables[0] to gridview then it will throw you an error
try as follows
if(ds.Tables.count>0)
{
if(ds.Tables[0]!=null)
{
grdView.DataSource = ds.Tables[0];
grdView.DataBind();
}
}