Hi,
I have a crystal report in my .net App. I want to fetch data from another server on report running on my machine. Hence, I pass connection dynamically in the code. The remote server will not have DSN configured. I should be able to pass all the details in code only. I do not want any ODBC dependency.
Following is the code snippet I use to pass these details:
ReportDocument rpt = new ReportDocument();
rpt.Load( pathToreport);
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = serverName;
crConnectionInfo.DatabaseName = DatabaseName;
crConnectionInfo.UserID = userName;
crConnectionInfo.Password = passwd;
CrystalDecisions.CrystalReports.Engine.Tables CrTables = rpt.Database.Tables;
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
crystalReportViewer1.ReportSource = rpt;
crystalReportViewer1.RefreshReport();
But,running this code gives me error saying,
Is there any specific format in which i shall pass the server name for this type of connection?
Or I am missing anything else?
Please help.