Crystal Report based on sql query with more than two tables

jason15871384916 2012-08-15 11:26:13
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).

...全文
130 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧