Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Link Multiple Tables in Crystal Report Foreign key Post Reply Post New Topic
Author Message
Brinda
Newbie
Newbie
Avatar

Joined: 27 Nov 2011
Online Status: Offline
Posts: 7
Quote Brinda Replybullet Topic: Link Multiple Tables in Crystal Report Foreign key
    Posted: 02 Apr 2014 at 1:49am
Hello ,
i'm New to Crystal report. i have 2 tables with primary and foreign key

Customer Details

EID - Primary Key

PurchaseDetails

PNo-Primary Key
PDate,
EID- Foreigh Key
NetAmount

Report Query written in c#

SELECT DISTINCT P.PNo, P.PDate, P.PM, P.DisAmt, P.LT, P.NT, P.EID, P.PTime, C.EName FROM PurchaseDetails AS P INNER JOIN CustomerDetails AS C ON P.EID = C.EID

In Report Automattically linked based key.
 
but report data not showing
can u plz anyone tell me solution for this . its very urgent!
            


Edited by Brinda - 02 Apr 2014 at 1:49am
Thanks & Regards
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 02 Apr 2014 at 4:27am
The query looks good.  But we do not know the data.  Do you have another way to access the data (Toad, MS-SQL Server Management Studio, etc.) to test that the query actually returns data.
IP IP Logged
Brinda
Newbie
Newbie
Avatar

Joined: 27 Nov 2011
Online Status: Offline
Posts: 7
Quote Brinda Replybullet Posted: 02 Apr 2014 at 6:43pm
S i checked in query browser its executed and returned data

This is my report loading code

DataSet dd = null;
dd = getdatasetfromquery("SELECT DISTINCT P.PNo, P.PDate, P.PM, P.DisAmt, P.NT,P.LT,P.EID,C.EName FROM PurchaseDetails AS P INNER JOIN CustomerDetails AS C ON P.EID = C.EID");

 Report_PurchaseAll_View report1 = new Report_PurchaseAll_View();
                                ConnectionInfo crConnectionInfo;
                                Tables crTables;
                                TableLogOnInfo crTableLogOnInfo;
                                crTables = report1.Database.Tables;
                                crConnectionInfo = new ConnectionInfo();
                                crConnectionInfo.ServerName = ValidationT_SQLC.Path;
                                crConnectionInfo.DatabaseName = ValidationT_SQLC.Name;

                                foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
                                {
                                    crTableLogOnInfo = aTable.LogOnInfo;
                                    crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                                    aTable.ApplyLogOnInfo(crTableLogOnInfo);
                                }
                                report1.SetDataSource(dd.Tables[0]);
                                crystalReportViewer1.ReportSource = report1;
                                crystalReportViewer1.Refresh();

 public DataSet getdatasetfromquery(string query)
        {
            DataSet ds = new DataSet();
            cmd = con.CreateCommand();
            cmd.CommandText = query.ToString();
            cmd.CommandType = CommandType.Text;
            da = new SqlCeDataAdapter(cmd);
            da.Fill(ds);
            return ds;
        }
Thanks & Regards
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 03 Apr 2014 at 7:45am
hmmm....
If you are setting the datasource for the report in code, you shouldn't need the tables, and if you are selecting the data tables in the report, you don't need the dataset...could that be what is happening...

what sort of data connection are you using?

If you use ADO.Net, you can stop your code after the ds is created, write out the ds to an xml file using ds.writexml(filename, includeSchema), the set your report to read the filename...you will have data and schema for designing the report.

Now in code, all you need is to get the ds, create the new report, set the datasource to ds and display the report. (this is pushing the data to the report)

If you are using another connection type, you probably don't have to worry about the datasource, the report will 'pull' the data from the database (this is the more typical setup for reporting, though I like to push the data myself).

HTH
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.