In my experience, it’s better to use datatable rather than dataset as CR’s
data source.
HTH
Elton Wang
(E-Mail Removed)
"Téo" wrote:
> I don't see my question with my newsreader, just try to post a last time,
> sorry if it's (one more...) bug of OE...
>
> Hi,
>
> I have created a crytal report based on a table of my SQL Server. Everything
> works fine.
> I would like now to fill my report with a sql request in the code behind
> instead of the table in the crystal report.
> But in the following code, the dataset created isn't "used" by the crystal
> report wich continues to use the table.
> And if i delete the table in the crystal report to use unbound fields, it
> doesn't work.
>
> Any idea?
>
> myCR = new CrystalReport1();
> myCR.SetDatabaseLogon("sa", "mypassword");
> SqlConnection cn=new SqlConnection(accessbdd.chaineSQL);
> SqlCommand cmd=new SqlCommand();
> cmd.Connection=cn;
> cmd.CommandText="SELECT TOP 10 * FROM Table1";
> cmd.CommandType=CommandType.Text;
> SqlDataAdapter da=new SqlDataAdapter(cmd);
> DataSet ds=new DataSet();
> da.Fill(ds);
> myCR.SetDataSource(ds);
> CrystalReportViewer1.ReportSource=myCR;
>
> Thanks.
>
>
>
>