crystal
-
hi everyone. I am quite new to vb.net 2005 and I have been trying to connect my database programmatically to my sql server database. I have moved from one error to the next and I have followed the steps highlighted in the msdn walk through on crystal reports. Every time I run my code, I am getting an error message that states that the load report event has failed. and the object reference has not been set to an instance of the object. I have tried this several times and I don't know what to do. If anyone can help me I would be most greatful. The code I have been trying to use is as follows. Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Public Class Form1 Private Sub ConfigureCrystalReports() Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo() myConnectionInfo.DatabaseName = "Northwind" myConnectionInfo.UserID = "user" myConnectionInfo.Password = "bob123" myConnectionInfo.ServerName = "chiko-shumba" Dim reportPath As String = Application.StartupPath & "\" & "NorthwindCustomers.rpt" myCrystalReportViewer.ReportSource = reportPath SetDBLogonForReport(myConnectionInfo) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ConfigureCrystalReports() End Sub Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo) Dim myTableLogOnInfos As TableLogOnInfos = myCrystalReportViewer.LogOnInfo For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos myTableLogOnInfo.ConnectionInfo = myConnectionInfo Next End Sub Private Sub myCrystalReportViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCrystalReportViewer.Load End Sub End Class