Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2011, 01:52 PM
Registered User
 
Join Date: Aug 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default passing parameters to crystal reports from c#

hi,

i have a windows form in which i have some combo boxes and check box and 2 date time picker.the data should be taken from combobox and filter according to check box and datetimepicker dates.how should i write stored procedure for this fields and pass it to crystal reports. any one help me out. my c# code is:
HTML Code:
private void button1_Click(object sender, EventArgs e)
      {
          ReportDocument rpt = new ReportDocument();
          //crtestreport rpt = new crtestreport();

          SqlCommand cmdcsp_workorder = new SqlCommand("sp_testspworkorder", con);
          cmdcsp_workorder.CommandType = CommandType.StoredProcedure;
           //cmdcsp_workorder.Parameters.Add
         //cmdcsp_workorder.Parameters.Add("@customername", SqlDbType.NVarChar, 50) = "";
          cmdcsp_workorder.Parameters.Add("@customername", SqlDbType.NVarChar, 50).Value = "APGB";
          cmdcsp_workorder.Parameters.Add("@regionname", SqlDbType.NVarChar, 50).Value = "APGB KADAPA";
          cmdcsp_workorder.Parameters.Add("@location", SqlDbType.NVarChar, 50).Value = "ANANTAPUR ";
          cmdcsp_workorder.Parameters.Add("@system", SqlDbType.NVarChar, 50).Value = "SAS";
          //cmdcsp_workorder.Parameters.Add("@district ", SqlDbType.NVarChar, 50).Value = cmbdistrict.SelectedValue;
          //cmdcsp_workorder.Parameters.Add("@engineer", SqlDbType.NVarChar, 50).Value = cmbengname.SelectedValue;
          //cmdcsp_workorder.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = dtpfromdate.Text ;
          //cmdcsp_workorder.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = dtptodate.Text ;
          //cmdcsp_workorder.Parameters.Add("@Branch", SqlDbType.VarChar, 50).Value = DDL_BranchName.SelectedValue;

          cmdcsp_workorder.Connection = con;

          SqlDataAdapter da = new SqlDataAdapter(cmdcsp_workorder);
          //DataSet ds = new DataSet(DataSetworkorder);
          //DBForSafetySystemsDataSet ds = new DBForSafetySystemsDataSet();
          DataSet ds = new DataSet();
          DataTable workorderdt = new DataTable();
          da.SelectCommand = cmdcsp_workorder;
          da.Fill(ds , "workorderdt");

          int rowcount = ds.Tables[0].Rows.Count;

          if (rowcount != 0)
          {
              //string reportPath = Server.MapPath("C:\\Documents and Settings\\Administrator.POSITIVE\\Desktop\\shivani\\MasterPage(30)\\MasterPage\\crtestreport.rpt");
             //string reportPath = Microsoft.SqlServer.Server.MapPath("..//crtestreport.rpt");

              rpt.Load("c:\\Users\\Mohan\\Desktop\\MasterPage(30)\\MasterPage\\crtestreport.rpt");
              //rpt.DataDefinition.FormulaFields["username"].Text = "'" + System.Environment.UserName.ToString() + "'";

              rpt.SetDataSource(ds.Tables[0]);
              crystalReportViewer1.ReportSource = rpt;
              crystalReportViewer1.Visible = true;
              //crystalReportViewer1.DataBind();
              //crystalReportSource1.DataBind();
              crystalReportViewer1.ReportSource = rpt;
              //CrystalReportViewer1.ShowAllPageIds = true;

          }

its urgent plz any one rectify my error and send.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing parameters to crystal reports at runtime tbhakee Crystal Reports 14 September 11th, 2013 05:49 AM
Passing Parameters to Crystal Reports 8.5 using VB6 Jun Fuderanan VB How-To 1 December 28th, 2009 10:04 AM
passing parameters to crystal reports Shubhi ASP.NET 2.0 Professional 0 July 4th, 2008 02:18 AM
Passing parameters w/o prompt to Crystal Reports VannAustin BOOK: Professional Crystal Reports for VS.NET 1 August 31st, 2006 08:46 AM
Passing Parameters to crystal reports through codi secrets Crystal Reports 0 April 5th, 2005 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.