Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
String query = "Select a.Account_No,d.Transaction_No,d.Amount_Debit,d.Debit_Date,d.Total_Amount_Debit,c.Transaction_No,c.Amount_Credit,c.Credit_Date,c.Total_Amount_Credit from Account_Debit d,Account_Credit c,Accounts a where c.Account_No=d.Account_No and d.Transaction_No=c.Transaction_No";

              da = new SqlDataAdapter(query, cn);
                   DataTable dt = new DataTable();
                   da.Fill(dt);
                   if (dt.Rows.Count == 0)
                   {
                       MessageBox.Show("The Complete Info of Account No'" + cboaccount1.Text + "-" + cboaccount2.Text + "'does not Exists!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                       cboaccount1.SelectAll();
                       cboaccount1.Focus();
                   }
                   else
                   {


                       DebitCrdit_rpt crt = new DebitCrdit_rpt();

                        crt.SetDataSource(dt);
                        Report_Viewer rpt = new Report_Viewer();
                        this.Close();
                        rpt.Show();
                        rpt.crystalReportViewer1.ReportSource = crt;
                        rpt.crystalReportViewer1.Refresh();
                        dt.Clear();
                        cn.Close();
                   }


               }
   }
Posted
Comments
bbirajdar 7-Jan-13 6:19am    
I tried executing the query.. It seems the database table does not have any data.. So it is not displayed

in else part...
VB
ReportDocument crt=New ReportDocument();
crt.Load("PUT CRYSTAL REPORT PATH HERE\DebitCrdit_rpt.rpt")
Report_Viewer rpt = new Report_Viewer();
crt.SetDataSource(dt);
crt.Database.Tables(0).SetDataSource(dt);
rpt.crystalReportViewer1.ReportSource = crt;
rpt.crystalReportViewer1.Refresh();
this.Close();
rpt.Show();
cn.Close();

Happy Coding!
:)
 
Share this answer
 
v6
Comments
zeshanazam 7-Jan-13 6:17am    
ThanX but same problem exists
Aarti Meswania 7-Jan-13 6:21am    
please check updated solution
and make sure datatable Dt have records (debug and check)
zeshanazam 7-Jan-13 6:23am    
datatable dt have records
zeshanazam 7-Jan-13 6:22am    
Non-invocable member 'CrystalDecisions.CrystalReports.Engine.Database.Tables' cannot be used like a method.
Aarti Meswania 7-Jan-13 6:28am    
sorry 'Database.Tables' used when accessing Reportdocument's object
Could you replace your else part below

else
     {


         DebitCrdit_rpt crt = new DebitCrdit_rpt();

          crt.SetDataSource(dt);
          Report_Viewer rpt = new Report_Viewer();
          this.Close();
          rpt.Show();
          rpt.crystalReportViewer1.ReportSource = crt;
          rpt.crystalReportViewer1.Refresh();
          dt.Clear();
          cn.Close();
     }


with


else
                  {


                      DebitCrdit_rpt crt = new DebitCrdit_rpt();

                       crt.SetDataSource(dt);
                       rpt.crystalReportViewer1.ReportSource = crt;
                       rpt.crystalReportViewer1.Refresh();
                       dt.Clear();
                       cn.Close();
                  }


and should work, any issues let me kow
 
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