I am new in crystal report development, i have developed one report with table in design time and provided the login information and getting the data , but when running the application its prompting again to enter the login details, i want to show the data when i click on that particular link. please suggest me how to do and i am pasting the code , which is in .cs file form load event.
var crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath("RouteDetails.rpt"));
crystalReport.SetDatabaseLogon("sa", "leo_123", @"172.20.0.25", "BBMS");
CrystalReportViewer1.ReportSource = crystalReport;
please help me in this regards as it is very urgent for me.
Vijay YadavPosted Feb 1, 2011, 7:19 AM
instead write
con = new SqlConnection(GetConnectionstring());
con.Open();
cmd = new SqlCommand(Query, con);
dr = cmd.ExecuteReader();
dt.Load(dr);
drRead.Close();
TableLogOnInfos crTableLogOnInfos = new TableLogOnInfos();
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables crTables;
crConnectionInfo.ServerName = "ServerName";
crConnectionInfo.DatabaseName = "dbname";
crConnectionInfo.UserID = "userId";
crConnectionInfo.Password = "Password";
crystalReport.SetDataSource(dt);
crTables = crystalReport.Database.Tables;
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
crystalReportViewer1.Refresh();
CrystalReportViewer1.ReportSource = crystalReport;
I hope this help you!!!
Thanks,
Vijay