I have made a cr with a few sections with subreports and I get the data from an SQL database with manually made commands in the report wizard. In this report I get dialog-boxes up to be able to enter variables to the commands at run-time. And if I load the report with this code it works great.
But I wanted to be able to choose the location of my database at runtime, then I tried several methods and this code seamed to work with a report without subreports.
But when I try to load my big report with all the sub reports it uses a very long time load the report, then I finally get my first dialog-box up to enter a value for the first sub-report, then I enter the value and I get an error about invalid argument for database. and the report is completely blank. anyone here has experience with this kind of sub-reports?
VB.NET:
Dim crp As New CrystalReport3
Me.CrystalReportViewer1.ReportSource = crp
Me.CrystalReportViewer1.RefreshReport()
But I wanted to be able to choose the location of my database at runtime, then I tried several methods and this code seamed to work with a report without subreports.
VB.NET:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class CR
Private Sub CR_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter
Dim crReportDocument As New CrystalReport1()
With crConnectionInfo
.ServerName = "SQLEXPRESS"
.DatabaseName = "Kalkyle1"
.UserID = "User2"
.Password = "user2"
End With
CrTables = crReportDocument.Database.Tables
For Each CrTable In CrTables
Try
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
CrTable.Location = "db_owner" + ".dbo." + CrTable.Name
Catch ex As Exception
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
End Try
Next
'Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReportDocument
'***************************************************************************
End Sub
End Class
But when I try to load my big report with all the sub reports it uses a very long time load the report, then I finally get my first dialog-box up to enter a value for the first sub-report, then I enter the value and I get an error about invalid argument for database. and the report is completely blank. anyone here has experience with this kind of sub-reports?