Hello,This is my code.I have in big problem anyone have a solution. I want view crystal Report by using studentid.

{

                CrystalReport1 objRpt;
                objRpt = new CrystalReport1();
                string con = ("Data source =DATA;Initial Catalog = Schooldata;Integrated security = True");
                SqlConnection objCon = new SqlConnection(con);
                // Here I am writing my query over the view
                // we cannot write query directly over the tables because it will be a 
                // join query and we will not be able to fill our adapter easily.
              string query = "Select StudentName from studentinfo where studentid=22";
                SqlDataAdapter dt = new SqlDataAdapter(query , objCon);
                DataSet1 Ds = new DataSet1();
                
                dt.Fill(Ds ,"studentinfo");

                //dt.Fill(Ds.Studentinfo , Convert.ToInt32(txtstudentid.Text));
             
                   if (Ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No REcord");
                    return;
                }

                objRpt.SetDataSource(Ds);
                CrystalDecisions.CrystalReports.Engine.TextObject root;
                root = (CrystalDecisions.CrystalReports.Engine.TextObject)
                objRpt.ReportDefinition.ReportObjects["txtHeader"];
                root.Text = "Sample Report With Parameter!!";
                crystalReportViewer1.ReportSource = objRpt;

when I press button Err (No Record found)

Any one can help me ?????//

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.