Crystal Report based on sql query with more than two tables

Crystal Reports
Visual Studio 2008
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.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

Answer Wiki

Thanks. We'll let you know when a new response is added.

its very easy u have to use below code for ur project

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;

catch(Exception ex)

Discuss This Question:  

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: