using CrystalDecisions.Reporting;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
private void displayReport()
{
try
{
CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
ConnectionInfo connInfo = new ConnectionInfo();
TableLogOnInfo tblLogInfo = new TableLogOnInfo();
TableLogOnInfos tblLogInfos = new TableLogOnInfos();
connInfo.UserID = "usrName";
connInfo.Password = "passwd";
connInfo.ServerName = "database";
tblLogInfo.ConnectionInfo = connInfo;
tblLogInfos.Add(tblLogInfo);
CrystalReportViewer1.LogOnInfo = tblLogInfos;
CrystalReportViewer1.EnableParameterPrompt = false;
CrystalReportSource1.ReportDocument.FileName=Server.MapPath ("Reports\\crystNewMain.rpt");
}
Catch
{
}
}
Most of the posts in this blog are the information I collected over the internet. I have looked for them for my own purpose and have posted here so that others might benefit as well
Showing posts with label crystal reports. Show all posts
Showing posts with label crystal reports. Show all posts
Monday, May 12, 2008
Saturday, May 10, 2008
How to pass parameter to crystal report from ASP.NET
Suppose there is a crystal report which expects parameter id and section. Here’s the code that shows how to pass the parameter through ASP.net
Before this please do not forget to use following namespaces
using CrystalDecisions.Reporting;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
private void displayReport(number id,string section)
{
try
{
CrystalReportViewer1.EnableParameterPrompt = false;
ParameterFields pFields = new ParameterFields();
ParameterField pField1 = new ParameterField();
ParameterField pField2 = new ParameterField();
ParameterDiscreteValue pDisValue1 = new ParameterDiscreteValue();
ParameterDiscreteValue pDisValue2 = new ParameterDiscreteValue();
pField1.Name = "id";
pField2.Name = "section";
pDisValue1.Value = id;
pField1.CurrentValues.Add(pDisValue1);
pFields.Add(pField1);
pDisValue2.Value = section;
pField2.CurrentValues.Add(pDisValue2);
pFields.Add(pField2);
CrystalReportViewer1.ParameterFieldInfo = pFields;
}
Catch
{
}
}
Before this please do not forget to use following namespaces
using CrystalDecisions.Reporting;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
private void displayReport(number id,string section)
{
try
{
CrystalReportViewer1.EnableParameterPrompt = false;
ParameterFields pFields = new ParameterFields();
ParameterField pField1 = new ParameterField();
ParameterField pField2 = new ParameterField();
ParameterDiscreteValue pDisValue1 = new ParameterDiscreteValue();
ParameterDiscreteValue pDisValue2 = new ParameterDiscreteValue();
pField1.Name = "id";
pField2.Name = "section";
pDisValue1.Value = id;
pField1.CurrentValues.Add(pDisValue1);
pFields.Add(pField1);
pDisValue2.Value = section;
pField2.CurrentValues.Add(pDisValue2);
pFields.Add(pField2);
CrystalReportViewer1.ParameterFieldInfo = pFields;
}
Catch
{
}
}
Subscribe to:
Posts (Atom)