我有一个像这样的vb.net代码:我正在使用vb.net windows窗体,我正在尝试执行包含3个子报告的水晶报告..我给出了这样的代码:
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 > 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 > 0) Then
rpt.Subreports(3).SetDataSource(ds3.Tables(0))
CrystalReportViewer1.ReportSource = rpt
End If
执行时我在此行中收到错误 rpt.Subreports(3).SetDataSource(ds3.Tables(0))
得到这样的错误: 指数超出范围。必须是非负数且小于集合的大小。 参数名称:index 我的代码出了什么问题,如果知道的话请帮我查一下