[英]Overload resolution failed because no accessible 'new' is most specific for these arguments
This is the code: 这是代码:
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
Problem is here: 问题在这里:
Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("",
TmpDS.TotalProfilForAllTime)
Error message: overload resolution failed because no accessible 'new'is most specific for these arguments. 错误消息:重载解析失败,因为对于这些参数,没有可访问的“新”是最特定的。
Depending on the type of TmpDS.TotalProfilForAllTime, cast the second argument passed to the constructor: 根据TmpDS.TotalProfilForAllTime的类型,强制转换传递给构造函数的第二个参数:
Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, DataTable))
or: 要么:
Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, IEnumerable))
etc. 等等
VB can't clearly pick the best constructor overload, so you have to provide some help to the compiler. VB无法清楚地选择最佳的构造函数重载,因此您必须为编译器提供一些帮助。 See this link for the possible 2nd argument types expected. 有关可能的第二个参数类型的信息,请参见此链接。 http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportdatasource.reportdatasource(v=vs.100).aspx This is a common problem in VB code since VB is not very strict about interpreting object types - it allows more variation in allowing one object type being used in place of another (especially with Option Strict Off). 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.