Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Linq
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.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
cryRpt.Load("C:\Users\dad\Desktop\report\myfile2.rpt")
With crConnectionInfo
.ServerName = "127.0.0.1"
.DatabaseName = "xxx"
.UserID = "sa"
.Password = "123456"
End With
CrTables = cryRpt.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Sub
End Class
I am getting the below error while trying to load crystal report in visual studio 2013.
An unhandled exception of type 'CrystalDecisions.Shared.CrystalReportsException' occurred in CrystalDecisions.CrystalReports.Engine.dll
Additional information: Load report failed.
On this line cryRpt.Load("C:\Users\dad\Desktop\report\myfile2.rpt")
The path is correct.