![](/img/trans.png)
[英]Overload resolution failed because no accessible 'New' is most specific for these arguments:
[英]Overload resolution failed because no accessible 'new' is most specific for these arguments
这是代码:
If ComboBox1.Text = "Total profil for all time" Then
Dim TA As New CPDBTableAdapters.TotalProfilForAllTimeTableAdapter
Dim TmpDS As New CPDB
TA.Fill(TmpDS.TotalProfilForAllTime)
'obriši prošli DS
RV.LocalReport.DataSources.Clear()
'dodaj novi DS
Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", TmpDS.TotalProfilForAllTime)
RV.LocalReport.DataSources.Add(RDS)
RV.LocalReport.ReportEmbeddedResource = "change_password.report1.rdlc"
RV.RefreshReport()
End If
问题在这里:
Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("",
TmpDS.TotalProfilForAllTime)
错误消息:重载解析失败,因为对于这些参数,没有可访问的“新”是最特定的。
根据TmpDS.TotalProfilForAllTime的类型,强制转换传递给构造函数的第二个参数:
Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, DataTable))
要么:
Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, IEnumerable))
等等
VB无法清楚地选择最佳的构造函数重载,因此您必须为编译器提供一些帮助。 有关可能的第二个参数类型的信息,请参见此链接。 http://msdn.microsoft.com/zh-cn/library/microsoft.reporting.winforms.reportdatasource.reportdatasource(v=vs.100).aspx这是VB代码中的常见问题,因为VB在解释方面不是很严格对象类型-在允许使用一种对象类型代替另一种对象类型时(尤其是在Option Strict Off下),它允许更多的变化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.