cancel
Showing results for 
Search instead for 
Did you mean: 

Link Multiple Tables in Crystal Report with Foreign Key c#

Former Member
0 Kudos

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

This is Code Loading Report Dynamically form C# windows Application

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;

        }

In Report Design Automattically linked based key .

 

But report data not showing ?

Can u plz anyone tell me solution for this.

Thanks & Regards

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Brinda

I've moved your post to the SAP Crystal Reports, version for Visual Studio SCN Space.

The code is confusing as you are both logging the report on to a database and creating a dataset. But I do not see you passing the dataset to the report. So a number of questions:

Does this report work in the CR designer?

At runtime, do you want to connect the report to the database, or do you want the report to consume a dataset?

Also, what version of CR are you working with? Please be precise.

What version of .NET?

What database? And version of the database.

Are you connecting to the database via ODBC, OLE DB, etc?

OS?

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Answers (0)