ReportDocument reportDoc = new ReportDocument();
reportDoc.Load(fileName);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.UserID = userName;
connectionInfo.Password = password;
connectionInfo.ServerName = odbcName;
connectionInfo.DatabaseName = databaseName;
foreach (Table table in reportDoc.Database.Tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}
crystalReportViewer1.ReportSource = reportDoc;
ASKER
ASKER
//Loop through all the sections to find all the sub reports
foreach (Section section in reportDoc.ReportDefinition.Sections)
{
//Loop through all the report objects to find all subreports
foreach (ReportObject reportObject in section.ReportObjects)
{
if (reportObject.Kind == ReportObjectKind.SubreportObject)
{
SubreportObject subreportObject = (SubreportObject)reportObject;
//Open the subreport object and logon as for the general report
ReportDocument subreportDoc = (ReportDocument)subreportObject.OpenSubreport(subreportObject.SubreportName);
foreach (Table table in subreportDoc.Database.Tables)
{
//Before Change
DisplayInfo("SUB REPORT BEFORE", table);
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
//After Change
DisplayInfo("SUB REPORT AFTER", table);
}
}
}
}
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
Have you deleted a user or changed passwords recently?
Many databases require passwords to be changed at set times say 30, 60, 90 days.
Can you change the data in the prompt?
If so use a known user and password.
mlmcc