Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
void BindCrystal()
        {
            string query = "select * from executive.employesallary";
            DataTable dt;
            dt = sampurnit.DataTable(query);

            SAMARPANN.Admin.CrystalReport1 crypt = new CrystalReport1();
            crypt.SetDataSource(dt);


            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load(@"D:\Samarpann_mannu\SAMARPANN\SAMARPANN\Admin\CrystalReport1.rpt");
            crystalReportViewer1.ReportSource = crypt;
            crystalReportViewer1.Refresh();

        } 

Connection is done through a class file ...
named sampurnit.cs
C#
public static DataTable DataTable(string query)
       {
               if (cn.State != ConnectionState.Open)
               {
                   cn.Open();
               }
               SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(query,cn);
               DataTable dt = new DataTable();
               da.Fill(dt);
               return dt;

       }
Posted
Updated 16-Dec-10 23:24pm
v3
Comments
Toli Cuturicu 20-Dec-10 16:36pm    
No question. You got my one, because there is no zero.

Start from here: Idiot's Guide to Crystal Reports, Part I - Winforms[^]

There are quite a few articles on crystal reports here at CodeProject itself. Please use the CPsearch if needed.
 
Share this answer
 
I think it's not a question(you posted in a wrong place), actually you should have posted this as a Tip/Trick[^] or Blog[^] in CP.
 
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