Hi,
Problem: Unable to Connect to Database at Runtime.
Reports are Created using a particular Database server and if we want to
change the database server still it connects to the previous database server only. We would like to know how to connect to the other Database server having the same structure as of the initial one. We are using OLE DB (ADO) for the connection purpose. The Below given code is also used at the time of reports creation.
Code:
public void CrystalReportlogin(ReportDocument report)
{
ConnectionInfo connection = new CrystalDecisions.Shared.ConnectionInfo();
CrystalDecisions.Shared.TableLogOnInfo log = new
CrystalDecisions.Shared.TableLogOnInfo();
connection.DatabaseName =
ConfigurationManager.AppSettings["DataBaseName"].ToString();
connection.ServerName =
ConfigurationManager.AppSettings["ServerName"].ToString();
connection.UserID = ConfigurationManager.AppSettings["UserID"].ToString();
connection.Password =
ConfigurationManager.AppSettings["Password"].ToString();
foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in
report.Database.Tables)
{
log = tbl.LogOnInfo;
log.ConnectionInfo = connection;
crvBlocksReceivedForTheMonth.LogOnInfo.Add(log);
}
}
Thanks & Regards,
Sreenivas Kaushik