vb.net Crystal Reports 打开连接失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28119692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 18:43:30  来源:igfitidea点击:

Crystal Reports failed to open the connection

vb.netcrystal-reports-xi

提问by Ardeth

I am developing a desktop software which is creating proposals and invoices. I am storing my database (MySql) in a remote server. Everything is working perfectly fine in my PC which i am using for coding.

我正在开发一个创建提案和发票的桌面软件。我将我的数据库 (MySql) 存储在远程服务器中。在我用于编码的 PC 中一切正常。

On client machine I can add,update and delete records without any problem. But when i try to open a record in then I am facing with an error below.

在客户端机器上,我可以毫无问题地添加、更新和删除记录。但是,当我尝试在其中打开记录时,我遇到了以下错误。

I was created the report in VB.NET but when I face with the error than I opened the rpt file in Crystal Reports XI Release 2 and updated data source location, verified database and save the file. Some part of my code is :

我是在 VB.NET 中创建报告的,但是当我遇到错误时,我在 Crystal Reports XI Release 2 中打开了 rpt 文件并更新了数据源位置,验证了数据库并保存了文件。我的代码的某些部分是:

ElseIf Me.Text = "Tekliflere G?zat" Then
            Form16.Text = "Teklif Detaylar?:"

            Dim strReportPath As String
            Dim rptDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
            strReportPath = My.Application.Info.DirectoryPath & "\Teklif.rpt"
            rptDoc = New ReportDocument
            rptDoc.Load(strReportPath)
            rptDoc.SetDatabaseLogon("USER_NAME", "PASSWORD", "SERVER_IP", "DB_NAME")
            Form16.CrystalReportViewer1.ReportSource = rptDoc


            Form16.CrystalReportViewer1.SelectionFormula = "{teklif1.teklifno} =" & ListView1.SelectedItems(0).Text
            Form16.CrystalReportViewer1.Refresh()
            Form16.CrystalReportViewer1.RefreshReport()
            Form16.Show()
            Me.Close()

Crystal reports Failed to open the connectionCould you please advise.
Thank you.
Regards
Oguz

水晶报表打开连接失败您能否提一些建议。
谢谢你。
问候
奥古兹

回答by Ardeth

I've found the solution. But first have to look at the casue. While connecting to a remote database via my software everthing is working fine. But when I was designing a report in CR, I created a connection in database expert menu. So that means locally I am describing to CR that where and how to connect. But when I install my software with all necessery components to the client machine CR report files searching the connection criteria and as a matter of course it can not find it in client machine.

我找到了解决方案。但首先要看看情况。通过我的软件连接到远程数据库时,一切正常。但是当我在CR中设计报表时,我在数据库专家菜单中创建了一个连接。所以这意味着我在本地向 CR 描述连接的位置和方式。但是,当我将带有所有必需组件的软件安装到客户端计算机时,搜索连接条件的 CR 报告文件当然无法在客户端计算机中找到它。

So the solution is to install Mysql ODBC Connector to the client machine and configure it with the same settings in my PC. Or as an alternative solution, define all connection and database settings programatically in your code.

因此,解决方案是将 Mysql ODBC Connector 安装到客户端计算机并在我的 PC 中使用相同的设置对其进行配置。或者作为替代解决方案,在您的代码中以编程方式定义所有连接和数据库设置。

Hope this helps.

希望这可以帮助。