473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Crystal Report and Requests

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.

Nov 19 '05 #1
3 1616
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.

Nov 19 '05 #2
In my experience, it’s better to use datatable rather than dataset as CR’s
data source.

HTH

Elton Wang
el********@hotmail.com
"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.

Nov 19 '05 #3
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.
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
13
by: kristoff plasun | last post by:
I have a problem with a C++ DCOM application that prints Crystal Reports with data from Oracle. The SQL query is relatively complex but when the report is printed from the Crystal Reports...
0
by: Danny J. Lesandrini | last post by:
First, this is _not_ a question about how to get Crystal Reports to run on a client machine. I've got all the merge modules added to the project and it's working fine. The question is about...
1
by: bthomas71chevy | last post by:
I have just setup a WebServer and all the applications work fine, but when every any of the applications try to generate a Crystal Report the page errors out. "File or assembly name...
0
by: Danny J. Lesandrini | last post by:
Didn't get any takers on this post this morning at dotnet.General, so I'm reposting here. First, this is _not_ a question about how to get Crystal Reports to run on a client machine. I've got...
3
by: ian_jacobsen | last post by:
First let me start by saying that this problem is not consistently reproducible. I have a windows service that creates reports for a group of entities. This service can process multiple groups at...
0
by: Aaron | last post by:
Hi, I am using crystal reports for VS 2003. I wanted to have a field on the report that would display which copy of report it was. So if the user requests 3 copies of report (for example,...
3
by: GaryDean | last post by:
This is really a licence question.... I want to deploy the version of Crystal Reports that comes with Visual Studio 2005 to a production server. Is there another license charge if the I'm...
11
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
How can I stop receiving this message while calling a crystal report? "The report you requested requires further information." Thanks
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.