title: index was out of range in vb .net while executing crystal report
body: <p>I have a vb.net code like this: i am working on vb.net windows form, am trying to execute crystal report that included 3 subreports..i given my code like this:</p>
  
  <pre><code>Dim locid As Integer = RecordID("Locid", "Location_tbl", "LocName", CmbLocations.Text)
          Dim ptime As Integer = TxtTime.Text
          'ViolatedRequested
          Dim cmd23 As New SqlCommand("IBS_Delivarysummaryviolatedrequested", con.connect)
          cmd23.CommandType = CommandType.StoredProcedure
          cmd23.Parameters.Add("@locid", SqlDbType.Int).Value = locid
          cmd23.Parameters.Add("@time", SqlDbType.Int).Value = ptime
          da.SelectCommand = cmd23
          da.Fill(ds)
          Dim rpt As New DelivarySummerystatuswiserpt
          ' If (ds.Tables(0).Rows.Count &gt; 0) Then
  
          rpt.SetDataSource(ds.Tables(0))
          ' CrystalReportViewer1.ReportSource = rpt
          '  End If
          'requested
          Dim cmdreqstd As New SqlCommand("IBS_Delivarysummaryrequested", con.connect)
          cmdreqstd.CommandType = CommandType.StoredProcedure
          cmdreqstd.Parameters.Add("@locid", SqlDbType.Int).Value = locid
          cmdreqstd.Parameters.Add("@time", SqlDbType.Int).Value = ptime
          da.SelectCommand = cmdreqstd
          da.Fill(ds1)
          rpt.Subreports(1).SetDataSource(ds1.Tables(0))
          ' CrystalReportViewer1.ReportSource = rpt
  
          ''  Parked
          Dim cmdparked As New SqlCommand("IBS_Delivarysummaryparked", con.connect)
          cmdparked.CommandType = CommandType.StoredProcedure
          cmdparked.Parameters.Add("@locid", SqlDbType.Int).Value = locid
          da.SelectCommand = cmdparked
          da.Fill(ds2)
          rpt.Subreports(2).SetDataSource(ds2.Tables(0))
          ' CrystalReportViewer1.ReportSource = rpt
  
          'violated Detaild
          Dim cmdvolatedDetaild As New SqlCommand("IBS_DelivarysummaryviolateDetaild", con.connect)
          cmdvolatedDetaild.CommandType = CommandType.StoredProcedure
          cmdvolatedDetaild.Parameters.Add("@locid", SqlDbType.Int).Value = locid
          cmdvolatedDetaild.Parameters.Add("@time", SqlDbType.Int).Value = ptime
          da.SelectCommand = cmdvolatedDetaild
          da.Fill(ds3)
          If (ds3.Tables(0).Rows.Count &gt; 0) Then
              rpt.Subreports(3).SetDataSource(ds3.Tables(0))
              CrystalReportViewer1.ReportSource = rpt
          End If
  </code></pre>
  
  <p>while executing i am getting error in  this line  <strong><em>rpt.Subreports(3).SetDataSource(ds3.Tables(0))</em></strong></p>
  
  <p>getting error like this:
  <em>Index was out of range. Must be non-negative and less than the size of the collection.
  Parameter name: index</em>
  what is wrong with my code,,if any know please help me to find out</p>