部署到客户端PC vb.net时,Crystal Reports项目不显示

时间:2018-07-07 05:54:34

标签: mysql vb.net winforms crystal-reports

在安装了数据库的服务器PC中运行该应用程序时,其工作并在数据库中显示项目,但是在客户端PC中安装并运行它时,则未显示任何错误。即时通讯使用vb.net 2013社区,将mysql用作数据库和SAP水晶报表版本13.0.12.1494,并且我正在使用odbc即时通讯连接我的数据库

这是它在我的服务器PC中工作的屏幕截图

working in my server pc

这是我的客户端PC上的一个,您可以看到我的列表视图正在读取并显示数据库中的项目,但是当我点击打印时,水晶报表显示为空

not wirking in my client pc

这是我的应用程序配置和模块连接中的连接字符串

App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>

  <connectionStrings>
    <add name="MySqlConnectionString" connectionString="SERVER=192.168.1.2;DATABASE=payparkingsystem;UID=connect;PASSWORD=password;" />
  </connectionStrings>

</configuration>

moduleconnection.vb。

Imports MySql.Data.MySqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Configuration
Module ModuleConnection

    Public connString1 As String = ConfigurationManager.ConnectionStrings("MySqlConnectionString").ToString()
    Public conn As MySqlConnection = New MySqlConnection(connString1)
    Public sql As String = ""

    Public Function ExecuteQuery(ByVal query As String) As DataTable
        Dim sqlDT As New DataTable
        Try
            Dim sqlCon As New MySqlConnection(connString1)
            Dim sqlDA As New MySqlDataAdapter(query, sqlCon)
            Dim sqlCB As New MySqlCommandBuilder(sqlDA)
            sqlDA.Fill(sqlDT)
        Catch ex As Exception
        End Try
        Return sqlDT
    End Function
End Module

这是我的打印代码

Public Sub PrintEmployeeAccountsLogsSearch()
        Dim cryRpt As New ReportDocument
        cryRpt.Load("C:\Reports\CrystalReportPrintEmployeeAccountsLogsSearch.vb.rpt")
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue
        crParameterDiscreteValue.Value = print
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("My Parameter")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
        FormPrintEmployeeAccountsLogsSearch.CrystalReportViewer1.ReportSource = cryRpt
        FormPrintEmployeeAccountsLogsSearch.CrystalReportViewer1.Refresh()
        cryRpt.PrintToPrinter(1, True, 0, 0)
    End Sub

这是我的数据库的屏幕截图

enter image description here

我希望有人能帮助我解决我的错误,对您的帮助将不胜感激。在此先感谢您和更多有能力的人!

1 个答案:

答案 0 :(得分:0)

您是否从客户端连接数据库?