I created Crystal report in .NET. Using DataSet as Datasource. If I include subreport in the report, "Database Login" appears to prompt for login. It works fine if I remove or supress the subreport.
I am using CR9. How can I solve this? Please help.
When you are accessing the database, you will need to provide the connection information for each table in your report/subreport.
Use ConnectionInfo object to setup it at runtime before you setting ReportSource property of the Crystal Report Viewer object.
All can be changed: database name, user, password, or even new server that is different that one that was setup when the report was designed.
So iterate through all tables accessed in report/subreport and set TableLogOnInfo property for each table.
TableLogOnInfo myLoginfo= new TableLogOnInfo();
myLoginfo.ConnectionInfo.DatabaseName =
myLoginfo.ConnectionInfo.Password=
myLoginfo.ConnectionInfo.Servername=
myLoginfo.ConnectionInfo.UserId=
-obislavu-
//Assumes you have a subreport called kanban3
//Assumes you have a dataset with 2 tables....I'm referencing the second table below.
CrystalDecisions.CrystalReports.Engine.ReportDocument report;
report.OpenSubreport("kanban3".SetDataSource(ds.Tables[1]);
//- rptClass is the Crystal Report .cs generated by VS.NET
//- dsMain is the dataset that we've got from database
//- we loop the ReportObject inside the report and if subreport is found, we
// will assign the according dataset into these subreports, until all
protected virtual void BuildReport() {
if (rptClass == null || dsMain == null)
return;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.