本文介绍了如何将Crystal报表连接到多个数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个有下拉列表的网页。在下拉列表中,有一个来自服务器的数据库列表。在选择下拉列表时,会显示文档编号,我们可以单击并生成水晶报告。
我的问题是我在水晶报告中为一个数据库提供了数据源。假设我选择了其他数据库。如何连接到多个数据库的报告?
任何输入都会非常感激。
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.
推荐答案
ReportDocument crReport = new ReportDocument();
crReport.Load("path and filename");
b)创建报告连接信息对象
b) Create a Report connection information object
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)将登录信息应用于每个报告表
c) Apply the Logon information to each report table
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);
}
这篇关于如何将Crystal报表连接到多个数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!