5 Replies - 6346 Views - Last Post: 08 March 2010 - 02:40 PM Rate Topic: -----

#1 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 62
  • Joined: 02-June 09

how to create report without using crystal report tool in c#

Posted 05 July 2009 - 11:14 PM

hi there

Please any one please give me idea how to create report in c# window application without using crystal repot
Is This A Good Question/Topic? 0
  • +

Replies To: how to create report without using crystal report tool in c#

#2 baavgai   User is offline

  • Dreaming Coder
  • member icon


Reputation: 7205
  • View blog
  • Posts: 15,017
  • Joined: 16-October 07

Re: how to create report without using crystal report tool in c#

Posted 06 July 2009 - 04:24 AM

Use HTML. Display it as an embedded web widget in your form. HTML is not great at page number and absolute positioning, but it's fine for presentation. A few third party products produce PDFs. Microsoft Reporting Services are often used as a replacement for Crystal.
Was This Post Helpful? 0
  • +
  • -

#3 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1534
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: how to create report without using crystal report tool in c#

Posted 06 July 2009 - 05:38 AM

There is a Report object that is part of Visual Studio. It's a decent reporting tool as long as the report isn't too complicated.

Right-Click on Project --> Add New Item --> Report.
Was This Post Helpful? 0
  • +
  • -

#4 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 62
  • Joined: 02-June 09

Re: how to create report without using crystal report tool in c#

Posted 06 July 2009 - 06:37 AM

hi there,
Thanks For reply
I did something like this but i didn't display any record in on screen
ConfigClass cnf = new ConfigClass();
		DataSet dsMyDataSet = new DataSet();
		string ReportPath = @"D:\bmsv1\MyTestReport.rdlc";
		
		public RptPatientVaccination()
		{
			InitializeComponent();
		}

		private void RptPatientVaccination_Load(object sender, EventArgs e)
		{
			this.cmbReport.Items.Add("TESTREPORT");
			this.SetupDataSet();
			this.reportViewer1.RefreshReport();
		}
		private void btnViewReport_Click(object sender, EventArgs e)
		{
			//reset the report viewer
			this.reportViewer1.Reset();

			//set processing to local mode
			this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;

			//check which report to test
			if (this.cmbReport.Text.Trim() == "TESTREPORT")
			{
				//load .rdlc file and add a datasource
				this.reportViewer1.LocalReport.ReportPath = ReportPath;
				//loop through each table in our dataset
				for (int i = 0; i < this.dsMyDataSet.Tables.Count; i++)
				{
					this.reportViewer1.LocalReport.DataSources.Add(this.GetMyDataTable(i));
				}
			}
			//refresh viewer with above settings
			this.reportViewer1.RefreshReport();

			RptPatientVaccination rp = new RptPatientVaccination();
			rp.InitializeReport("Customer Report", "Customers", reportSourceFile, new ReportDataSource(dataSetName + "_" + dataTableName, dsReport.Tables[0]));
		}

		private Microsoft.Reporting.WinForms.ReportDataSource GetMyDataTable(int i)
		{
			//form the datasource name - you need a naming convention for this to work
			string sDataSourceName = "Reportdata_Table" + i.ToString().Trim();

			//the line above will generate datasource names of "Reportdata_Table0" and
			//"Reportdata_Table1" for our 2 tabled dataset - we just need to ensure our .rdlc
			//report has been designed to receive 2 datasources with these same names, and that
			//the columns match up pecisely one-to-one for each table.

			//return the relevant dataset table
			return new Microsoft.Reporting.WinForms.ReportDataSource(sDataSourceName,this.dsMyDataSet.Tables[i]);
		}

		private void SetupDataSet()
		{
			//create 1st DataTable to hold some report data
			System.Data.DataTable myTable0 = new DataTable("myTable0");
			System.Data.DataColumn column;
			System.Data.DataRow row;

			//create 3 columns
			column = new DataColumn();
			column.DataType = System.Type.GetType("System.String");
			column.ColumnName = "ID";
			column.ReadOnly = true;
			column.Unique = true;

			// Add the Column to the DataColumnCollection.
			myTable0.Columns.Add(column);
			column = new DataColumn();
			column.DataType = System.Type.GetType("System.String");
			column.ColumnName = "DESCRIPTION";
			column.ReadOnly = true;
			column.Unique = true;

			// Add the Column to the DataColumnCollection.
			myTable0.Columns.Add(column);
			column = new DataColumn();
			column.DataType = System.Type.GetType("System.String");
			column.ColumnName = "QUANTITY";
			column.ReadOnly = true;
			column.Unique = true;

			// Add the Column to the DataColumnCollection.
			myTable0.Columns.Add(column);

			//add a row of data
			row = myTable0.NewRow();
			row["ID"] = "1234567890";
			row["DESCRIPTION"] = "Rickenbacker Electric Guitar";
			row["QUANTITY"] = "5";

			//add the row of data to the table
			myTable0.Rows.Add(row);

			//and a second row
			row = myTable0.NewRow();
			row["ID"] = "777745632";
			row["DESCRIPTION"] = "Gibson Electric Guitar";
			row["QUANTITY"] = "7";

			//add the row of data to the table
			myTable0.Rows.Add(row);

			//add myTable0 to global dataset
			this.dsMyDataSet.Tables.Add(myTable0);//dsMyDataSet.Tables[0] object;

			//create 2nd DataTable to hold some report data
			System.Data.DataTable myTable1 = new DataTable("myTable1");

			//create 4 columns
			column = new DataColumn();
			column.DataType = System.Type.GetType("System.String");
			column.ColumnName = "CUSTOMER_ID";
			column.ReadOnly = true;
			column.Unique = true;

			// Add the Column to the DataColumnCollection.
			myTable1.Columns.Add(column);
			column = new DataColumn();
			column.DataType = System.Type.GetType("System.String");
			column.ColumnName = "NAME";
			column.ReadOnly = true;
			column.Unique = true;

			// Add the Column to the DataColumnCollection.
			myTable1.Columns.Add(column);
			column = new DataColumn();
			column.DataType = System.Type.GetType("System.String");
			column.ColumnName = "ADDRESS";
			column.ReadOnly = true;
			column.Unique = true;

			// Add the Column to the DataColumnCollection.
			myTable1.Columns.Add(column);
			column = new DataColumn();
			column.DataType = System.Type.GetType("System.String");
			column.ColumnName = "POSTAL_CODE";
			column.ReadOnly = true;
			column.Unique = true;

			// Add the Column to the DataColumnCollection.
			myTable1.Columns.Add(column);

			//add a row of data
			row = myTable1.NewRow();
			row["CUSTOMER_ID"] = "56790";
			row["NAME"] = "John Lennon";
			row["ADDRESS"] = "Strawberry Fields , Liverpool , England";
			row["POSTAL_CODE"] = "NWE232";

			//add the row of data to the table
			myTable1.Rows.Add(row);

			//add a row of data
			row = myTable1.NewRow();
			row["CUSTOMER_ID"] = "44982";
			row["NAME"] = "George Harrison";
			row["ADDRESS"] = "22 Penny Lane , Liverpool , England";
			row["POSTAL_CODE"] = "NWE231";

			//add the row of data to the table
			myTable1.Rows.Add(row);

			//add myTable1 to global dataset
			this.dsMyDataSet.Tables.Add(myTable1);//dsMyDataSet.Tables[1] object;
		}

		private void BtnExit_Click(object sender, EventArgs e)
		{
			this.Close();
		}



		public void InitializeReport(string formName, string reportDisplayName, string reportPath, ReportDataSource reportDataSource)
		{

			this.Text = formName;

			this.reportViewer.Reset();
			this.reportViewer.LocalReport.DisplayName = reportDisplayName;

			this.reportViewer.DocumentMapCollapsed = true;


			this.reportViewer.LocalReport.ReportPath = reportPath;
			this.reportViewer.Messages = this.customMessages;
			this.reportViewer.LocalReport.DataSources.Add(reportDataSource);
			this.reportViewer.RefreshReport();
		}


Please help me i really want to create a report without using crystal report component.
Was This Post Helpful? 0
  • +
  • -

#5 nhrakesh   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-June 09

Re: how to create report without using crystal report tool in c#

Posted 08 July 2009 - 07:38 AM

View Post[email protected], on 5 Jul, 2009 - 10:14 PM, said:

hi there

Please any one please give me idea how to create report in c# window application without using crystal repot




i have an idea use RDLC REPORTS

i have an idea use RDLC REPORTS
Was This Post Helpful? 0
  • +
  • -

#6 Guest_iming*


Reputation:

Re: how to create report without using crystal report tool in c#

Posted 08 March 2010 - 02:40 PM

A sample report in VB .NET can be found at http://www.microtool...rtFAQs.htm#QD63 and the code can be easily converted to C#. It's a report without using Crystal Reports or SQL Reporting Services and is designed for desktop application use.
Was This Post Helpful? 0

Page 1 of 1