Skip to Content
avatar image
Former Member

how to show data set in crystal report viewer?

I have one dataset that fills from 3 table;

I want to show dataset in crystal report viewer.

string StrCommand = "SELECT Person.Name, Person.Family,Problem.Date,Problem.Time,Problem.PID, Problem.MID,Person.Ward,Problem.Title,Problem.Explain,Problem.Response,Problem.Response2,Problem.Committee,Problem.Reformact from Management2group  INNER JOIN  Problem ON Management2group.MID = Problem.MID INNER JOIN Person ON Problem.PID = Person.PID where Problem.MID=" + MID + " and (Problem.Date BETWEEN '" + start + "' and '" + end + "')and (@Family='' OR Family like CONCAT(@Family, '%')) and (@Name='' OR Name like CONCAT(@Name, '%') )";
                // 
                SqlCommand cmd = new SqlCommand(StrCommand, con);
                cmd.Parameters.AddWithValue("Family", family.Text);
                cmd.Parameters.AddWithValue("Name", name.Text);
              
        //        cmd.Parameters.AddWithValue("name", name.Text);
        //
                crystal.Clear();
                 SqlDataAdapter adp = new SqlDataAdapter(cmd);
                adp.Fill(crystal );
                dataGridViewX2.DataSource = crystal.Tables[0];
 print button code---->
Problemprint1 prt = new Problemprint1();
            rptproblemprint rpt = new rptproblemprint();
            //DataTable dt = crystal.Tables[0];
            rpt.SetDataSource(dataGridViewX2.DataSource);
            prt.crystalReportViewer1.ReportSource = rpt;
            prt.crystalReportViewer1.RefreshReport();
            prt.ShowDialog();
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers