各位大大:
請問出現下列錯誤狀況,是何原因??
System.InvalidCastException: '無法將類型 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' 的 COM 物件轉換為介面類型 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'。由於發生下列錯誤,介面 (IID 為 '{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}') 之 COM 元件上的 QueryInterface 呼叫失敗而導致作業失敗: 不支援此種介面 (發生例外狀況於 HRESULT: 0x80004002 (E_NOINTERFACE))。'
=========程式碼如下============
Private Sub ButtonReport_Click(sender As System.Object, e As System.EventArgs) Handles ButtonReport.Click
Select Case CbBoxReportName.Text
Case "到期未校驗量具一覽表" '截止日期>=待校日期 報廢 免校 不顯示
ShareClass.dsReports.Tables("SMS10").Clear()
DataGridView1.DataSource = ShareClass.Get_Report1(DTP1.Text).Tables("SMS10")
Dim cr As New Report1
cr.SetDataSource(ShareClass.dsReports)
With cr
'.PrintOptions.PaperOrientation = PaperOrientation.Landscape '直印
'.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize
End With
CrystalReportViewer1.ReportSource = cr
CrystalReportViewer1.Refresh()
CrystalReportViewer1.Zoom(0.75)
If CbBoxpreview.CheckState = CheckState.Checked Then
Else
'全部直接印出
cr.PrintToPrinter(1, True, 0, 0)
End If