I have designed some reports in C#.net. I have used the Database Files option in Crystal report wizard.The path to all reports are the same, but now i have moved the database to other location, i only chaned the connection string in my application. Now the application runs fine, but while viewing reports, it gives problem and asks for username and password....
Should i create DSN of that path and use it in crystal reports, but than i have to redesign all reports....
Is there anyother way to view reports....
Loading
Master BillaPosted Oct 12, 2009, 12:32 PM
This is simple, you need set connection information to report.
private void cmdPrint_Click(System.Object sender, System.EventArgs e)
{
string strReportPath = null;
strReportPath = "summery.rpt";
// Load the selected report file.
//
ReportDocument CR = new ReportDocument();
CR.Load(strReportPath);
CrystalDecisions.Shared.TableLogOnInfo crConnectionInfo = new CrystalDecisions.Shared.TableLogOnInfo();
crConnectionInfo.ConnectionInfo.ServerName = "server";
crConnectionInfo.ConnectionInfo.DatabaseName = "password";
crConnectionInfo.ConnectionInfo.UserID = "uername";
crConnectionInfo.ConnectionInfo.Password = "password";
// Here we need assign connection to every tables.
for (int index = 0; index <= CR.Database.Tables.Count - 1; index++) {
CR.Database.Tables(index).ApplyLogOnInfo(crConnectionInfo);
}
CrystalReportViewer1.ReportSource = CR;
}
now load it won't ask the username and pasword
thank you