C# .NET - how to bring data from database in crystal report

Asked By Sohel Shaikh on 14-Feb-14 08:33 AM
Hi, 
I want to bring the data from table (using where clause ) into crystal report but when i am running the report form it is showing all the data from the table my query is fine but the code is given below please say : whether it is fine or not :  -
help will be greatly appreciated....
//cryRpt.Load(Application.StartupPath + "\\PhotoBill.rpt");
            crconnection.ServerName = Common.DefaultDatabasePath;
            crconnection.DatabaseName = DatabaseName;
            crconnection.UserID = "Admin";
            crconnection.Password = "Surat@007";
 
            crtables = cryRpt.Database.Tables;
            //cryRpt.SetDataSource(dsreport);
             
            foreach (Table Crtable in crtables)
            {
               
              crtableinfo = Crtable.LogOnInfo;
              crtableinfo.ConnectionInfo = crconnection;
              Crtable.ApplyLogOnInfo(crtableinfo);
            }
 
            //crystalReportViewer1.ReportSource = cryRpt;
            ////DataTable dt = new DataTable();
            ////dt = dsreport.Tables[0];
             
            ////crystalReportViewer1.ReportSource = dt;
            //crystalReportViewer1.Refresh();
 
            cryRpt.Load(Application.StartupPath + "\\PhotoBill.rpt");
            cryRpt.SetDataSource(dsreport);
            crystalReportViewer1.ReportSource = cryRpt;
            crystalReportViewer1.Refresh();

  /


Robbe Morris replied to Sohel Shaikh on 14-Feb-14 08:36 AM
You just populate your DataTable with the rows you want from your where clause.  You do this outside of Crystal Reports.
Sohel Shaikh replied to Robbe Morris on 14-Feb-14 08:50 AM
Can you provide code for it as i am stuck for 15 days and it's very frustrating
Robbe Morris replied to Sohel Shaikh on 14-Feb-14 08:53 AM
https://www.nullskull.com/articles/20030729.asp