Skip to Content
0
Former Member
Apr 03, 2014 at 04:59 AM

Link Multiple Tables in Crystal Report with Foreign Key c#

188 Views

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