thanx for ur suggestion .....
mam,
i know how create the stored procedure but i dont know how to imlement its parameter with crystal report .....can u give me the on example please....i am new in crystal reports....so please give me the example ....
Nilanka DharmadasaPosted Jan 4, 2010, 11:52 PM
What you want to know is how to pass selected dates and other data as parameters to the crystal report. I can help you on that.
Use following code.
//First Create report document instance and load the report. Write your other code.
ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(".....");
......
Then set your parameter "@StartDate". Let's say the value you want to set is datetimepicker1's value.
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
ParameterValues currentParameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = datetimepicker1.Value.ToString();
currentParameterValues.Add(parameterDiscreteValue);
ParameterFieldDefinition parameterFieldDefinition = "@StartDate";
parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
Similarly you can set the values for other parameters too.
If you still cannot nderstand, please upload your code. Then I can surely help you.
paul danielPosted Jan 7, 2010, 8:58 AM
Passing parameters with crystal report
public partial class _Default : System.Web.UI.Page
{
private ReportDocument report = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
report.Load(Server.MapPath("CrystalReport.rpt"));
report.FileName = Server.MapPath("CrystalReport.rpt");
if (!Page.IsPostBack)
{
BindData();
}
}
protected override void OnUnload(EventArgs e)
{
base.OnUnload(e);
this.Unload+=new EventHandler(Page_Unload);
}
public void Page_Unload(object sender, EventArgs e)
{
// clean up the resources
report.Clone();
report.Dispose();
}
private void BindData()
{
string connectionString = @"Server=localhost;Database=Northwind;Trusted_Connection=true";
SqlConnection myConnection = new SqlConnection(connectionString);
SqlDataAdapter ad = new SqlDataAdapter("SELECT CategoryName,CategoryID FROM Categories", myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
ddlCategory.DataSource = ds;
ddlCategory.DataTextField = "CategoryName";
ddlCategory.DataValueField = "CategoryID";
ddlCategory.DataBind();
}
Thanks,
Paul daniel
Lalit MPosted Jan 5, 2010, 1:15 AM
http://usingcrystal.com/6982.html?*session*id*key*=*session*id*val*
http://www.informit.com/articles/article.aspx?p=683066&seqNum=3