This exception is given when you try to access an object (a reference type) that is null
(This object doesn't reference to any object's instance).
Probably, the value of ds
is null
or, there is no table that is called "registration".
You can change lines 3 - 6 to:
DataTable dt = ds != null ? ds.Tables["registration"] : null;
DataRow[] rs = dt != null ? dt.Select("umail='" + t1.Text.Trim() + "'") : null;
int r = rs != null ? rs.Length : 0;