Request to enter the database when clicking on subreports
I have a report and when I click on the subreport link I get a database login form. I gave all the required connection strings, but still it asks for login details for login.sub on my local system, but when installing on client system, I get This problem. what am i missing or what should i do?
0
a source to share
1 answer
I found that when setting up a database connection in code for a crystal report, you need to establish a connection for each individual table in the report database definition. You can do it like this:
private static void SetConnectionInfo(ReportClass report, string ReportServer, string ReportDatabase)
{
TableLogOnInfo tInfo = new TableLogOnInfo();
ConnectionInfo connectionInfo = tInfo.ConnectionInfo;
connectionInfo.IntegratedSecurity = true;
connectionInfo.ServerName = ReportServer;
connectionInfo.DatabaseName = ReportDatabase;
foreach (Table t in report.Database.Tables)
{
t.ApplyLogOnInfo(tInfo);
}
foreach (ReportClass subReport in report.Subreports)
{
SetConnectionInfo(subReport, ReportServer, ReportDatabase);
}
}
+1
a source to share