Vb.net – Failed to open the connection [Crystal Report]

crystal-reportscrystal-reports-2010vb.net

I'm receiving this error when I load the form that uses Crystal Report:

Failed to open the connection Details: [Database Vendor Code: 17]
Failed to open the connection. ReportMonthly {…}.rpt Details:
[Database Vendor Code: 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

Best Answer

Create the connection manual

rptDoc.Load(strReportPath)
rptDoc.SetDatabaseLogon("user", "password", "host", "dbname");
CrystalReportViewer1.ReportSource = rptDoc
CrystalReportViewer1.Refresh()
Related Topic