Object reference not set to an instance of an object
This error simply means that some object value is null and yet you are trying to use it somewhere directly or using it's properties.
Using DEBUGGER can tell you the exact object. When you got this error, you already know the line (which you have not mentioned here). Even if you are not aware, a simple debugging would tell you that.
Now here,
most probably the error is in line:
cr.OpenSubreport("CrystalReport1.rpt").SetDataSource(ds.Tables["table"]);
You are trying to open a subreport using a method 'OpenSubreport' but you have no where defined that the crystal report object 'cr' has one.
Read on how to add subreports dynamically through code.