3 Replies - 3469 Views - Last Post: 21 May 2012 - 11:06 AM Rate Topic: -----

#1 nicolae1ceausescu@yahoo.co  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-May 12

Crystal Reports and multiple tables query problems

Posted 19 May 2012 - 02:26 PM

Hi guys!
I'm developing an app and I've encountered some problems using Crystal Reports.
I'm using a select statement that pulls data from 3 tables, but only the data from the first table it's shown in the report.

string query = @"SELECT TBL_Dept.ID_Dept, TBL_Dept.Dept, 
                                   TBL_Func.ID_Func, TBL_Func.Functie, 
                                   TBL_Users.ID_User, TBL_Users.Email, 
                                    TBL_Employee.ID_Emp, TBL_Employee.First_Name, TBL_Employee.Last_Name,      
                                    TBL_Employee.ID_User, TBL_Employee.ID_Func, TBL_Employee.ID_Dept 
                            FROM   TBL_Dept, TBL_Func, TBL_Users, TBL_Employee
                             WHERE  TBL_Employee.ID_User = TBL_Users.ID_User AND TBL_Employee.ID_Func = 
TBL_Func.ID_Func AND TBL_Employee.ID_Dept = TBL_Dept.ID_Dept";


 OleDbDataAdapter oleDA = new OleDbDataAdapter(query, _accesConn);

 DataTable dt = new DataTable();

oleDA.Fill(dt);

objRpt.SetDataSource(dt);

crystalReportViewer1.ReportSource = objRpt;




Using this code only shows the date from the TBL_Employee table in the report.

I've also adapted the code like this:
string query = @"SELECT TBL_Dept.ID_Dept, TBL_Dept.Dept, 
                                   TBL_Func.ID_Func, TBL_Func.Functie, 
                                   TBL_Users.ID_User, TBL_Users.Email, 
                                    TBL_Employee.ID_Emp, TBL_Employee.First_Name, TBL_Employee.Last_Name,      
                                    TBL_Employee.ID_User, TBL_Employee.ID_Func, TBL_Employee.ID_Dept 
                            FROM   TBL_Dept, TBL_Func, TBL_Users, TBL_Employee
                             WHERE  TBL_Employee.ID_User = TBL_Users.ID_User AND TBL_Employee.ID_Func = 
TBL_Func.ID_Func AND TBL_Employee.ID_Dept = TBL_Dept.ID_Dept";


 OleDbDataAdapter oleDA = new OleDbDataAdapter(query, _accesConn);

DataSet ds = new DataSet();
 oleDA.Fill(ds, "Tables");
  objRpt.SetDataSource(ds.Tables[0]);


Using this code also displays the data from the Employee table.

I've also tried this:
ReportDocument rpt = new ReportDocument();
rpt.Load(@"|myPath|\myRpt.rpt");
crystalReportViewer1.ReportSource = rpt; 



None of these versions of code displays the data from all 3 tables.
I'm using Vs 2008 and an access 2007 database.

Is This A Good Question/Topic? 0
  • +

Replies To: Crystal Reports and multiple tables query problems

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Crystal Reports and multiple tables query problems

Posted 21 May 2012 - 05:36 AM

If you run the query in Access, does it return what you want?
Was This Post Helpful? 0
  • +
  • -

#3 nicolae1ceausescu@yahoo.co  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-May 12

Re: Crystal Reports and multiple tables query problems

Posted 21 May 2012 - 10:32 AM

Yes, the query works in Access and in VS2008 Query Builder and it returns the needed rows. However, in the Crystal Report, only the data from the Employee table is shown.
Was This Post Helpful? 0
  • +
  • -

#4 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,673
  • Joined: 24-August 11

Re: Crystal Reports and multiple tables query problems

Posted 21 May 2012 - 11:06 AM

You might be incorrectly binding data points to your report. You also may want to check your layout. We had problems with a Crystal Report not displaying query results, and it turns out that there was a little bit of overlap between labels and so one of them just wasn't displaying.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1