Click here to Skip to main content
15,793,098 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
            for (int c = 0; c < dataGridView1.Rows.Count - 1; c++)
                SqlDataAdapter da = new SqlDataAdapter("select * from student_details,institution_details where current_class='" + this.dataGridView1.Rows[c].Cells[0].Value + "'", Connection.con);

                DataSet ds = new DataSet();
                da.Fill(ds, "classlist");

                ReportDocument bkng = new ReportDocument();
                bkng.Load(Application.StartupPath + "\\Classlist.rpt");
                PrinterSettings print = new PrinterSettings();
                //pass parameters
                //pass year
                string strParameter1 = "";
                strParameter1 = Convert .ToString (this.dataGridView1.Rows[c].Cells[0].Value);
                bkng.SetParameterValue("Class", strParameter1);
                bkng.PrintOptions.PrinterName = print.PrinterName;
               //break point is at this line
                bkng.PrintToPrinter(1, false, 0, 0);
Updated 3-Feb-14 22:36pm

1 solution

aspx page:
<cr:crystalreportviewer id="CrystalReportViewer1" runat="server" xmlns:cr="#unknown">
AutoDataBind="true" DisplayGroupTree="False"
EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False" />

.cs page:

ReportDocument report = new ReportDocument();
report.Load(Application.StartupPath + "\\Classlist.rpt") //report name report.SetParameterValue(0, "abc"); // provide parameter value
report.SetDatabaseLogon(username, password,server,database);
CrystalReportViewer1.ReportSource = report;
Share this answer
Member 10501144 5-Feb-14 2:50am    
thanks you guys are doing great job just worked for me.

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