Subscribe to Subscribers

Forums » .NET » .NET »

Dataset to Crystal Report....


Posted Date: 20 Aug 2012      Posted By:: Lawrence     Member Level: Gold    Member Rank: 321     Points: 5   Responses: 3



Hi Everyone,
I would like to bind dataset values to crystal report or Report viewer..... Here is my coding...I bind dataset then how how to bind dataset to crystal report..... Just tell me... Here is my coding....

Coding:
cn.Open();
cmd = new SqlCommand("select standard, Section, Medium, sum(distinct Male) as Boys, sum( distinct Female) as Girls, sum(Male)+sum(Female) AS Total from (select Standard,[Section], Medium,(case when Sex='M' then count(Sex) else '0' end) as Male, (case when Sex='F' then count(Sex) else '0' end) as Female from student WHERE Medium='" + DropMedi.SelectedItem.Text + "' AND Standard IN(" + value + ") GROUP BY Standard,[Section],sex,Medium) a group by Standard,Section,Medium", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);


How to do...Just tell me....

Thanks In Advanced




Responses

#684766    Author: RayalaHariKishore      Member Level: Gold      Member Rank: 52     Date: 20/Aug/2012   Rating: 2 out of 52 out of 5     Points: 0

hi,
go through this article so you can do it by yourself , this is step by step tutorial.

Rayala HariKishore

try..try..try...you achieved it.
http://rayalaharikishore.wordpress.com/


 
#684767    Author: saravanakumar      Member Level: Gold      Member Rank: 196     Date: 20/Aug/2012   Rating: 2 out of 52 out of 5     Points: 4

hi see this,

 SqlDataAdapter da = new SqlDataAdapter("select * from out_gatematerial where gatepass_no='" + passno.Trim() + "'", con);
DataSet ds = new DataSet();
da.Fill(ds, "table");
con.Close();
Gate_Material_out cry = new Gate_Material_out();
cry.SetDatabaseLogon("asp_apps", "asp_apps", "SUNARKSBS", "MM", true);
cry.RecordSelectionFormula = "{out_gatematerial.gatepass_no}=" + passno.Trim() + "";
cry.SetDataSource(ds.Tables[0]);
crys_viewer.ReportSource = cry;
crys_viewer.DataBind();


 
#684826    Author: Ravindran        Member Level: Diamond      Member Rank: 3     Date: 20/Aug/2012   Rating: 2 out of 52 out of 5     Points: 4

Lawernce

follow the steps easily you can display crystal report

[First create XML dataset .xsd Right Click your project name -> ADD new Item ->dateset (.xsd) add new column (for your table field names)

Then Right Click your project name -> ADD new Item ->Choose Crystal report and name it as CrystalReport1.rpt.

Choose Field explorer in Left side and right click database Field -> Choose Database expert->choose new ADO.Net connection in tree and choose your dataset path and click finsih.. then your fields are dislayed in field explorer drag and drop in crystal report

Design side
--------------
create one new form and drag and drop crystal report viewer control in that form.

Code behind
------------

using System.Data;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
namespace winSampleCSharp
{
public partial class Form1 : Form
{
//Create table emp(eno int,empname varchar(50),sal bigint)
//insert some records too in that table
SqlConnection sqlcon = new SqlConnection(@"Server=RAVI-PC\SQLEXPRESS;database=test1;uid=ravindran;pwd=srirangam;");
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
sqlcon.Open();
sqlcmd = new SqlCommand("select * from emp", sqlcon);
da = new SqlDataAdapter(sqlcmd);
da.Fill(ds);
dt = ds.Tables[0];
CrystalReport1 objReport = new CrystalReport1();
objReport.SetDataSource(dt);
crystalReportViewer1.ReportSource = objReport;
sqlcon.Close();
}
}
}


still you struggle in this refer my attached source below

Regards
N.Ravindran
Your Hard work never fails



CrypRptCsharp.rar


 
Post Reply
You must Sign In to post a response.

Next : Call the connection string from App.config for Windows Application
Previous : Creating setup projecy of window application along with sql server database
Return to Discussion Forum
Post New Message
Category:

Related Messages

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2013 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.