将Crystal Reports连接到SQL Server的问题

问题描述 投票:1回答:1

我有问题

我是使用SQL的项目工作者vb.net 2015

我清除了项目并在客户端尝试了该项目之后

[通过水晶报表显示报表时出现错误

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim rpt As New WaznRep
    For Each DSC As CrystalDecisions.Shared.IConnectionInfo In rpt.DataSourceConnections
        DSC.SetLogon(muser, mpass)
        DSC.SetConnection(mserver, mdb, False)
    Next

    ReportV1.CrystalReportViewer1.ReportSource = rpt
    ReportV1.ShowDialog()
End Sub

服务器=服务器

mdb =数据库名称

muser =用户名sql

mpass = sql密码

它们是从文本文件中检索的

在客户端不打开报告时运行程序时

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9PTXlhNS5qcGcifQ==” alt =“在此处输入图像描述”>

此消息出现,数据库名称为空

并且我使用其他代码连接

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button3.Click
    Application.DoEvents()
    Dim rpt1 As New WaznRep
    Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
    ConInfo.ConnectionInfo.ServerName = mserver
    ConInfo.ConnectionInfo.DatabaseName = mdb
    ConInfo.ConnectionInfo.UserID = muser
    ConInfo.ConnectionInfo.Password = mpass
    rpt1.Database.Tables(0).ApplyLogOnInfo(ConInfo)
    ReportV1.CrystalReportViewer1.ReportSource = rpt1
    ReportV1.CrystalReportViewer1.RefreshReport()
    ReportV1.ShowDialog()
End Sub

花药

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.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
    Dim rpt1 As New WaznRep
    cryRpt.Load("D:\1.rpt")

    With crConnectionInfo
        .ServerName = mserver
        .DatabaseName = mdb
        .UserID = muser
        .Password = mpass
    End With

    CrTables = cryRpt.Database.Tables
    For Each CrTable In CrTables
        crtableLogoninfo = CrTable.LogOnInfo
        crtableLogoninfo.ConnectionInfo = crConnectionInfo
        CrTable.ApplyLogOnInfo(crtableLogoninfo)
    Next
    ReportV1.CrystalReportViewer1.ReportSource = cryRpt
    ReportV1.CrystalReportViewer1.RefreshReport()
    ReportV1.ShowDialog()
End Sub

所有代码都可以在我的PC上运行,但不能在客户端PC上运行

在我的PC和客户端PC中,相同的Crystal报告版本

编辑----

 Dim rpt As New WaznRep
    For Each DSC As CrystalDecisions.Shared.IConnectionInfo In rpt.DataSourceConnections
        DSC.SetConnection(mserver, mdb, False)
        DSC.SetLogon(muser, mpass)

    Next
    rpt.SetDatabaseLogon(muser, mpass)

    ReportV1.CrystalReportViewer1.ReportSource = rpt
    ReportV1.ShowDialog()

当我使用集成安全性= false时

数据库名称不显示

integrated security=false

当我使用集成安全性=真时

 Dim rpt As New WaznRep
    For Each DSC As CrystalDecisions.Shared.IConnectionInfo In rpt.DataSourceConnections
        DSC.SetConnection(mserver, mdb, True)
        DSC.SetLogon(muser, mpass)

    Next
    rpt.SetDatabaseLogon(muser, mpass)

    ReportV1.CrystalReportViewer1.ReportSource = rpt
    ReportV1.ShowDialog()

enter image description here

显示数据库名称,但不能在客户端PC中使用

sql database vb.net crystal-reports report
1个回答
0
投票

解决问题的方法

必须安装NATIVE SQL驱动程序才能访问Crystal Reports。

© www.soinside.com 2019 - 2024. All rights reserved.