I was given a task of rewriting some Crystal Reports. I found the original reports circa 1999, opened them up in VS 2008 made the changes and saved them.
Now, they reference a database that is no longer around. So, I deleted this data source and added a .NET OBJECT datasource. I changed everything around so that the fields now look at this new datasource.
My intent was to create the report and during run time, pass it a datatable. This table is created by running a sproc created.
When I run it, I get the first page of the report. But when I try to change pages or print, I get an error:
Logon failed. Details: crdb_adoplus : Object reference not set to an instance of an object. Error in File C:...\MR01 {8E5164A9-4B01-4019-81E6-87AED65A02DF}.rpt: Unable to connect: incorrect log on parameters
Here is my code:
<CR:CrystalReportViewer ID="theCrystalReportViewer" visible="false" runat="server" EnableDatabaseLogonPrompt="false" />
Dim theDataTable As DataTable = tbl
theDataTable.TableName = "tableName"
Dim oReport As New ReportDocument
Dim sRptPath As String = "...Reports\MR01.rpt"
oReport.Load(sRptPath)
oReport.SetDataSource(theDataTable)
'oReport.SetDatabaseLogon("####", "####", "####", "#####")
Dim c As ConnectionInfo = New ConnectionInfo()
c.ServerName = "####"
c.DatabaseName = "####"
c.Password = "####"
c.UserID = "####"
c.Type = ConnectionInfoType.SQL
c.IntegratedSecurity = False
For i As Integer = 0 To theCrystalReportViewer.LogOnInfo.Count - 1
theCrystalReportViewer.LogOnInfo(i).ConnectionInfo = c
Next
'theCrystalReportViewer.EnableDatabaseLogonPrompt = False
'theCrystalReportViewer.DisplayGroupTree = False
theCrystalReportViewer.ReportSource = oReport
theCrystalReportViewer.DataBind()
litMsg.Visible = False
theCrystalReportViewer.Visible = True