参数计数不匹配。在setDataSource上

时间:2013-08-08 14:22:24

标签: vb.net visual-studio-2012 crystal-reports

我正在尝试以下内容,我的报告中也没有参数,我也使用.Net Objects

 Dim data = GetDataConnection()
 Dim ds = (From th In data.TranHeads Where th.THCSCode = "YYY001"
              Select th).ToList

 Dim crySalesTran As ReportDocument = New IBS_DAL.rep_SalesTransaction

 crySalesTran.SetDataSource(ds.AsEnumerable)

 CrystalReportViewer1.ReportSource = crySalesTran

出于某种原因,当它达到setdatasource

TargetParameterCountException
参数计数不匹配。

1 个答案:

答案 0 :(得分:0)

我找到了答案虽然不确定为什么这样做而另一个选项却没有

Dim da = New System.Data.SqlClient.SqlDataAdapter("SELECT THSysRef, THCSCode FROM TranHead Where THCSCode = "YYY001" ", data.Connection)
Dim dtTH = New DataTable
da.Fill(dtTH)

Dim crySalesTran As ReportDocument = New IBS_DAL.rep_SalesTransaction
crySalesTran.Database.Tables(0).SetDataSource(dtTH)

CrystalReportViewer1.ReportSource = crySalesTran