to pass textbox value to crystal report without using database


  • Hi ,

    I am trying to pass data from C# form to crystal report ....
    I am not at all using database to get the data ....
    In c # form i am having one text box and one button.....
    i added one crystal report to my application....
    To crystal report in page header i added one text box item ...

    After running application i am adding some text in text box and then clicking the button,
    the data which i typed in text box must reflect in crystal report.......

    Please help me ,
    I am very new to crystal reports and .net

    Ravinder Reddy
    Friday, September 25, 2009 10:54 AM


All replies

  • Hi Ravinder,

    Check this Link .... this will be helpfull to you...


    Sharp Eyes
    Sharp Eyes
    Friday, September 25, 2009 11:22 AM
  • Thanks for post it  is  useful to me

    Actually I am looking for bill printing application for a firm where i want  to enter the goods  details and there prices in a table  format .....

    the User  will enter the goods in the C# form and just print th bill after entering all the goods list for customer.....

    Can u help me out with some simple code where i can get a billing application ......

    Friday, September 25, 2009 1:56 PM
  • Are you storing the data in the database?

    If not are you storing the data in a datagridview?

    If you are storing the data in a datagridview then check this link?


    This link will explain you how to create a crystal report from datagridview....

    The same you can use to create crystal report from your form....

    If you need further clarification post some of your code here so that we can understand what you want to do.... 

    Sharp Eyes
    • Marked as answer by Harry Zhu Friday, October 02, 2009 2:11 AM
    Friday, September 25, 2009 2:34 PM
  • Hi,
      If you don't have any database.
      Then just use Dataset.
      Add New Item---->DataSet1.xsd.
      After right click on dataset Add--->Columns--->
      Create some column-->
      On runtime send your data from form to this dataset.

     Then on your crystal report select ------> Database Expert ------> ADO.Net Dataset--->DataSet1.
     get the fields from their.

     Drop fields on crystal report.
     then add code of you code behind

     DataSet1 ds = new DataSet1();
     	    DataTable t = ds.Tables.Add("Items");
                t.Columns.Add("id", Type.GetType("System.Int32"));
                t.Columns.Add("Item", Type.GetType("System.String"));
                DataRow r ;
                int i = 0;
                for (i = 0; i <= 9; i++)
                    r = t.NewRow();
                    r["id"] = i;
                    r["Item"] = "Item" + i;
                CrystalReport1 objRpt = new CrystalReport1();
                crystalReportViewer1.ReportSource = objRpt;

    Monday, October 05, 2009 1:45 PM
  • Hi what i undestand is that, you need to print value of a windows textbox1  in creports and that value comes from user or data base is that so ?then here is the very simple solution for it.Just a simple logic here.all you need to do is :


    1.Frst create a parameter in the paraeterField in the DatabaseFileds, name it crParam.

    2.ReportDocument cryRpt = new ReportDocument();
     cryRpt.Load(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\CrystalReportsWithParam\CrystalReportsWithParam\CrystalReportsWithParam\CrystalReport1.rpt");


                ParameterFieldDefinitions crParameterFieldDefinitions ;
                ParameterFieldDefinition crParameterFieldDefinition ;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();


                crParameterDiscreteValue.Value = textBox1.Text;
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields ;
                crParameterFieldDefinition = crParameterFieldDefinitions["crParam"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;




                crystalReportViewer1.ReportSource = cryRpt;



    now drag and drop that paramter crParam on crystalReport where ever you want to display in

    that's it

    Do reply to me if this code works for your

    thank you

    Happy Coding



    Thursday, July 08, 2010 2:58 PM