5 pts.
 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). so, am using the sql query to get the data from the sqlserver2008 and get the data to the report, but what am getting a screen asking some information to logon as below : The report you requested requires further information. [hr class="promptRuler" /> [table border="0" cellpadding="0" cellspacing="2"> [tbody] [tr] [td colspan="2">  DataSet1 [/td] [/tr] [tr] [td align="left">Server name: [/td] [td][Input style="border-style: inset; width: 200px;" value="DataSet1" type="text" />[/td] [/tr] [tr] [td align="left">Database name: [/td] [td][Input style="border-style: inset; width: 200px;" type="text" />[/td] [/tr] [tr] [td align="left">User name: [/td] [td][Input style="border-style: inset; width: 200px;" type="text" />[/td] [/tr] [tr] [td align="left">Password: [/td] [td][Input style="border-style: inset; width: 200px;" type="password" />[/td] [/tr] [tr] [td][Input style="border-style: none;" value="on" type="checkbox" /> Use Integrated Security [/td] [/tr] [tr] [td] [/td] [td align="right">[Input style="border-style: outset;" value="Log On" type="button" />[/td] [/tr] [/tbody] [/table] i tried many many things to solve that but nothing at all working, even i tried the previous postes but nothing ... please if some one can help me out ... thanks in advance ...

Software/Hardware used:
Visual Studio 2008, Crystal Report and C#.net
ASKED: August 19, 2009  10:56 PM
UPDATED: October 16, 2011  9:55 AM

Answer Wiki:
its very easy u have to use below code for ur project try { TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); ConnectionInfo crConnectionInfo = new ConnectionInfo(); Tables CrTables; cr.Load("C:\Users\NOOR-UL-AIN\Documents\Visual Studio 10\Projects\invoice\invoice\commercial invoice\commercial invoice\MyReport.rpt"); crConnectionInfo.ServerName = "your server name"; crConnectionInfo.DatabaseName = "database"; crConnectionInfo.UserID = "userid"; crConnectionInfo.Password = "password"; CrTables = cr.Database.Tables ; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { crtableLogoninfo = CrTable.LogOnInfo; crtableLogoninfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(crtableLogoninfo); } } catch(Exception ex) { MessageBox.Show(ex.Message); }
Last Wiki Answer Submitted:  October 16, 2011  9:54 am  by  Skyengineer   15 pts.
All Answer Wiki Contributors:  Skyengineer   15 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _