Crystal Report based on sql query with more than two tables
Hi All, i have a big problem with the crystal report … my code is :
ReportDocument RD = new ReportDocument();
string ConnectionString = ConfigurationManager.ConnectionStrings["zaza">.ConnectionString;
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
SqlDataAdapter adp = new SqlDataAdapter("SELECT kund2.fornamn, kund2.efternamn, kund2.namn, kund2.telenr, kund2.mobilnr, kund2.faxnr, kund2.epost, kund2.persnr, kund2.fakgata1,kund2.fakgata2,kund2.fakpostaddrs, kund2.fakpostnr, kontrakt.Leadsource, kontrakt.KontraktID, kontrakt.KundID, Bokningar.seid, Produktyper.ProduktNamn FROM Bokningar INNER JOIN kund2 INNER JOIN kontrakt ON kund2.KundID = kontrakt.KundID ON Bokningar.KontraktID = kontrakt.KontraktID INNER JOIN Produktid ON Bokningar.ProduktID = Produktid.ProduktID INNER JOIN Produktyper ON Produktid.ProduktTypID = Produktyper.ProduktTypID WHERE(kontrakt.Seid = '2')", conn);
DataTable tb = new DataTable();
adp.Fill(tb);
RD.Load(Server.MapPath("CrystalReport.rpt"));
CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
myReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
myReportDocument.SetDatabaseLogon("test","test");
crv1.ReportSource = myReportDocument;
crv1.DataBind();
RD.SetDataSource(tb);
crv1.ReportSource = RD;
crv1.DataBind();
crv1.RefreshReport();
[/pre]
i alrady added to the project a dataset file (DataSet1.xsd) and
containes 4 tables from sqlserver 2008 tables are (kund2, kontrakt,
Produktyper, Bokningar).