在vb.net中加载crystal报表时出错

在vb.net中加载crystal报表时出错,vb.net,crystal-reports,Vb.net,Crystal Reports,我在visual studio 2013中尝试加载crystal report时遇到以下错误 CrystalDecisions.CrystalReports.Engine.dll中发生类型为“CrystalDecisions.Shared.CrystalReportsException”的未处理异常 其他信息:加载报告失败 在这一行cryRpt.Load(“C:\Users\dad\Desktop\report\myfile2.rpt”) 路径正确。您可以尝试变体 Imports System.

我在visual studio 2013中尝试加载crystal report时遇到以下错误

CrystalDecisions.CrystalReports.Engine.dll中发生类型为“CrystalDecisions.Shared.CrystalReportsException”的未处理异常

其他信息:加载报告失败

在这一行
cryRpt.Load(“C:\Users\dad\Desktop\report\myfile2.rpt”)

路径正确。

您可以尝试变体

Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Linq
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        Dim crtableLogoninfos As New TableLogOnInfos
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table


        cryRpt.Load("C:\Users\dad\Desktop\report\myfile2.rpt")


        With crConnectionInfo
            .ServerName = "127.0.0.1"
            .DatabaseName = "xxx"
            .UserID = "sa"
            .Password = "123456"
        End With

        CrTables = cryRpt.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next

        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class

我不知道它现在是否有效,但我将链接放在报告所在的位置,以字符串形式,因此

purchdocReport=New ReportDocument()

Dim reportPath As String=“C:\…\report\purchase\u inv1.rpt”
purchdocReport.Load(报告路径)


试试这个。。。我想如果你试试这个,你会很高兴的

Report.Load(ReportTemplateFullName, _
    CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
导入CrystalDecisions.CrystalReports.Engine
导入System.IO
公开课表格1
私有子按钮1\u单击(发送者作为对象,e作为事件参数)处理按钮1。单击
将报告作为新的报告文档
Dim strreportpath为String=Path.GetFullPath(_
Path.Combine(Application.StartupPath,“您的报告位置”)&_
“\sample.rpt”
cryReport.Load(strreportpath)
如果lvFemale.SelectedItems(0).Text“”,则
cryReport.RecordSelectionFormula=“{tbl_Sample.sampleID}=”&ListView.SelectedItems(0).Text
如果结束
FORM1.CrystalReportViewer1.ReportSource=CrystalReport
FORM1.CrystalReportViewer1.Refresh()
端接头
末级
Imports CrystalDecisions.CrystalReports.Engine
Imports System.IO
Public Class Form1

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim cryReport As New ReportDocument
Dim strreportpath As String = Path.GetFullPath( _
Path.Combine(Application.StartupPath, "Your Report Location")) & _
        "\sample.rpt"

    cryReport.Load(strreportpath)
    If lvFemale.SelectedItems(0).Text <> "" Then
        cryReport.RecordSelectionFormula = "{tbl_Sample.sampleID} = " & ListView.SelectedItems(0).Text
    End If
    FORM1.CrystalReportViewer1.ReportSource = cryReport
    FORM1.CrystalReportViewer1.Refresh()
End Sub
End Class