vb.net 打开连接失败【水晶报告】
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18033855/
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
Failed to open the connection [Crystal Report]
提问by Harvey
I'm receiving this error when I load the form that uses Crystal Report:
我在加载使用 Crystal Report 的表单时收到此错误:
Failed to open the connection Details: [Database Vendor Code: 17] Failed to open the connection. ReportMonthly {...}.rpt Details: [Database Vendor Code: 17]
无法打开连接详细信息:[数据库供应商代码:17] 无法打开连接。ReportMonthly {...}.rpt 详细信息:[数据库供应商代码:17]
I've researched on google about this error and so I find this site. I tried the steps or the instructions there but it didn't work meaning the same error.
我在谷歌上研究过这个错误,所以我找到了这个网站。我尝试了那里的步骤或说明,但没有奏效,这意味着同样的错误。
Here is the part of the code in my form:
这是我表单中的代码部分:
Private Sub FRViolators_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ShowReport(My.Application.Info.DirectoryPath & "\ReportMonthly.rpt")
End Sub
Public Sub ShowReport(ByVal strReportPath As String)
Dim rptDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
rptDoc = New ReportDocument
rptDoc.Load(strReportPath)
CrystalReportViewer1.ReportSource = rptDoc
CrystalReportViewer1.Refresh()
End Sub
回答by Gunawan Kamplong
Create the connection manual
创建连接手册
rptDoc.Load(strReportPath)
rptDoc.SetDatabaseLogon("user", "password", "host", "dbname");
CrystalReportViewer1.ReportSource = rptDoc
CrystalReportViewer1.Refresh()

