hi,
i'm using crystal report and my question is how to create a crystal report which displays fields from 2 tables. i tried this
code but nothing displays in the report

SqlCeConnection con = new SqlCeConnection();
            con.ConnectionString = @" Data source= |DataDirectory|\Database1.sdf";
            con.Open();
            Database1DataSet ds  = new Database1DataSet();
            
            
            SqlCeParameter paramNom = new SqlCeParameter("@nom", nomimprimerTextBox.Text);
            SqlCeParameter paramPrenom = new SqlCeParameter("@prenom", prenomimprimerTextBox.Text);
            SqlCeDataAdapter da = new SqlCeDataAdapter("Select Personne.[Nom],Personne.[Prenom],Personne.[DateNaissance],Personne.[LieuNaissance],Bulletin.[Autorite],Bulletin.[DateJ] from (Personne inner join Bulletin on Personne.[CodePersonne]=Bulletin.[CodePersonne])where Personne.[Nom]=@nom and Personne.[Prenom]=@prenom", con);
            da.SelectCommand.Parameters.Add(paramNom);
            da.SelectCommand.Parameters.Add(paramPrenom);
            
            da.Fill(ds,"Personne ");
            
           
            CrystalReport2 cr2 = new CrystalReport2();
            
            cr2.SetDataSource(ds);
            
            crystalReportViewer1.ReportSource = cr2;
            crystalReportViewer1.Refresh();

thank you

Try running that statement in SQL browser

Select Personne.[Nom],Personne.[Prenom],Personne.[DateNaissance],Personne.[LieuNaissance],Bulletin.[Autorite],Bulletin.[DateJ] from (Personne inner join Bulletin on Personne.[CodePersonne]=Bulletin.[CodePersonne])where Personne.[Nom]=@nom and Personne.[Prenom]=@prenom"

Does this T-SQL script work? inner joins\nestes queries make you get fields from multiple tables, did you try it?
Please tell me what you want to get from the tables? I think it AdventureWorks database, isn't it?

CrystalReport2 cr2 = new CrystalReport2();
what it is??
for this line of code there is any need to import any file...???

This article has been dead for over six months. Start a new discussion instead.