Click here to Skip to main content
15,909,324 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have a webpage which has a dropdown. In the dropdown there is a list of databases from a server. On selecting the dropdown document numbers are shown and we can click and generate crystal report.

My problem is I have given datasource for one database in the crystal report. Suppose I select other databases. How can I connect to the report for multiple databases?

Any inputs will be greatly appreciatd.
Posted

1 solution

Basic approach with Crystal Reports is as follows;
NOTE: Ensure to add references to the following Crystal objects;
CrystalDecisions.CrystalReports.Engine;
CrystalDecisions.Shared;
CrystalDecisions.Web;

a) Load the Report document
C#
ReportDocument crReport = new ReportDocument();
crReport.Load("path and filename");

b) Create a Report connection information object
C#
ConnectionInfo crConn = new ConnectionInfo();
crConn.ServerName = "my db server name";
crConn.DatabaseName = "my database name";
crConn.UserID = "db user name";
crConn.Password = "db password";

c) Apply the Logon information to each report table
C#
Tables tblsReport = crReport.Database.Tables;
for(int i=0; i<tblsreport.count;i++)>
{
Table tblReport = tblsReport[i];
TableLogOnInfo tliTable = tblReport.LogOnInfo;
tliTable.ConnectionInfo = crConn;
tblReport.ApplyLogOnInfo(tliTable);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900