After searching internet and answers here I am still not in a position of getting my problem resolved, I'm trying to use crystal report in c# Windows Form Application. I used Field Explorer in .rpt file to populate database fields in crystal report. then using the following code I called .rpt file in form (Comments below were added later by exploring the internet.)
//ReportDocument report = new ReportDocument();
//TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
//TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
// Tables CrTables ;
// report.Load("rpt_DailyLog.rpt");
Reports.rpt_GRN report = new Reports.rpt_GRN();
// ConnectionInfo crConnectionInfo = new ConnectionInfo();
//report.Load("rpt_GRN.rpt");
//crConnectionInfo.ServerName = ".\sql2008";
//crConnectionInfo.DatabaseName = "ARM";
//crConnectionInfo.UserID = "sa";
//crConnectionInfo.Password = "test123";
stringcondition = "{GRN.Date}='" + date + "'";
report.RecordSelectionFormula = stringcondition;
//CrTables = report.Database.Tables ;
//foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
//{
// crtableLogoninfo = CrTable.LogOnInfo;
// crtableLogoninfo.ConnectionInfo = crConnectionInfo;
// CrTable.ApplyLogOnInfo(crtableLogoninfo);
//}
//crystalReportViewer1.LogOnInfo.Item(0).ConnectionInfo.UserID = "sa"
//crystalReportViewer1.LogOnInfo.Item(0).ConnectionInfo.Password = "sapassword"
crystalReportViewer1.ReportSource = report;
crystalReportViewer1.Refresh();
Issue is: I am getting prompt when crystal report is loaded to give password while other fields i.e server name, database name and username is automatically populated, while it asks only for password. I don't want this prompt. Kindly help