PC Review


Reply
Thread Tools Rate Thread

Crystal Report and Requests

 
 
Téo
Guest
Posts: n/a
 
      12th Aug 2005
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.



 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2FyYXZhbmFuIEsgVg==?=
Guest
Posts: n/a
 
      12th Aug 2005
Hi,

If you want to use a DataSet as datasource for a crystal report, you need to
create a typed dataset and use this typed dataset when designing the report.

Then, from your code behind, you can create an instance of the typed dataset
and fill with the data. Then call this method.

myCR.SetDataSource(ds);

There is no need for calling SetDatabaseLogon("sa", "mypassword");


--
Saravanan K V


"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.
>
>
>
>

 
Reply With Quote
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      12th Aug 2005
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.
>
>
>
>

 
Reply With Quote
 
Téo
Guest
Posts: n/a
 
      13th Aug 2005
Thanks, do you have a tutorial link or an example ?
In fact, the request on wich the CR is based, is changing ("WHERE num_id>" +
TB1.Text, for example), so i don't want to create the source of the CR at
"design time".
I have to do it dynamically in the code behind...

Thanks.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report NON enterprise edition: simultaneous user requests siddharthkhare@hotmail.com Microsoft C# .NET 0 17th Jan 2009 09:15 PM
How to have access to the fields in the crystal report using VB.NET (outside the design of the crystal report) with SQL statements? amiga500@gmail.com Microsoft Dot NET 0 24th Oct 2007 04:38 PM
Sending Crystal Report to Network Print Mailbox While Bypassing Crystal Report Viewer. John Smith Microsoft VB .NET 0 17th Jan 2007 04:17 PM
Change Crystal Report Zoom Level using percentages in Crystal Report Viewer (Dotnet) Alex Stevens Microsoft Dot NET Framework Forms 1 30th Jun 2004 12:34 PM
Change Crystal Report Zoom Level using percentages in Crystal Report Viewer (Dotnet) Alex Stevens Microsoft Dot NET 1 30th Jun 2004 12:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:38 AM.