Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

 
Share this answer
 
 
Share this answer
 
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.
 
Share this answer
 
<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... !!!
 
Share this answer
 
you can try to use

http://ankwebsoft.in/programs/default.php?id=Visual%20C%23&subt=Generate%20CrystalReport[^]

here step by step process is represented for development of crystal report using visual c#.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900