Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
How to create crystal reports using C# code. i want to retrieve record from sql server to crystal report using C# code and i want to some rows are calculate to sum function.
how to write code. please give me crystal report's C# code.
Posted 19-Apr-12 0:35am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hello
 
First of all add crystal report viewer to your Form on which you want to add crystal report.
 
Now go to add new Item Menu and Select CrystalReport from there.
 

Go with using report wizard
 
Go to Create New Connections
 
For access select -DAO
For SQL select - ADO
 
then SQL Native Clients
then Server Name, Database and set Integrated Security=true
then select database name
then select table name
then selet fields to display in reports
then next->next-> and select Table Format and finish
Your Crystal report is ready
 
Now in C# Create Datasource of the record you want to show in report and set reports datasource.
This is all done.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

<pre lang="c#">
private DataTable GetValueFromSP()
{
                  //Your Sql Logic here to fetch data from database. 
                  SqlConnection cnn=new SqlConnection(""); --your connection string
                  SqlCommand cmd=new SqlCommand(cnn);
                  cmd.CommandTex="SELECT * FROM [Table1]";
                  
                  DataTable tblResult=cmd.ExecuteNonQuery();
                  return(tblResult);
 
}
private void SetReport()
{
             ReportDocument rd=new ReportDocument();
             rd.SetDataSource(GetValueFromSP());
               
             CrystalReportViewer1.Report=rd;
 
}
 
Ignore some kind of errors... !!!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,805
1 OriginalGriff 6,696
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,792


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 20 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100