Search code examples
c#sql-server-2005crystal-reports

C# Crystal report argument out of range exception


I am creating a crystal report @c# program but when I execute the report its working at first but when I execute the same report at second time I am having this error.

I use view to sql server to retrieve my data.

 cmd = new SqlCommand("Select * From referral where referralNo = '" + 
 lblReferral.Text + "' and clientNo = '" + cbClientNo.Text + "'", con);
 cmd.CommandType = CommandType.Text;
 da.SelectCommand = cmd;
 da.Fill(ds, "referral");
 rp.SetDataSource(ds);
 f3.crt.ReportSource = rp;   
 f3.Show();
 rp.Close();

I am having this error.

 An unhandled exception of type 'System.ArgumentOutOfRangeException' 
 occurred in System.Windows.Forms.dll

 Additional information: Index 0 is out of range.

then these are the instances

 CrystalReport1 rp = new CrystalReport1();
 SqlDataAdapter da = new SqlDataAdapter();
 DataSet ds = new DataSet();
 reportViewer f3 = new reportViewer();

Error @reviewing the report


Solution

  • I figured out the answer to my problem, it prompts an argument exception because the program, I called form via form.Show() instead form.ShowDialog().