473,424 Members | 1,909 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,424 software developers and data experts.

using Crystal Reports to display data in my dataset correctly (display the data I selected instead of all the data in table)

JK
In my win form, I'm trying to display a Crystal report with the data in my
dataset only but, if I follow the steps in this msdn page:

http://msdn.microsoft.com/library/de...tinaviewer.asp

it always displays all the data regardless of the Select statement I run.
Here's my code:

InitializeComponent();
//my code

CrystalReport1 oRpt = new CrystalReport1(); //CrystalReport1.rpt - it
contais 3 fields from table ClientData: clientid, fname, lname

SqlConnection SQLConn = new SqlConnection("Data Source=localhost; Integrated
Security=SSPI;" +

"Initial Catalog=invoicing");

string strThisQuery = "select clientid, fname, lname from ClientData where
clientID = 4"; /it returns only one record

SqlDataAdapter MyDataAdapterClients = new SqlDataAdapter (strThisQuery,
SQLConn);

DataSet DS_MyReportsDS = new DataSet();

MyDataAdapterClients.Fill(DS_MyReportsDS, "ClientData");

oRpt.SetDataSource (DS_MyReportsDS);

crystalReportViewer1.ReportSource = oRpt;
It doesn't matter what my Select returns, it'll always display all the data
in ClientData. I posted a similar message a few days ago, and someone posted
this:
"If it contains the schema of all the columns, the CrystalReportViewer will
display all the data in the table regardless of your select." but I really
didn't understand what he meant. How would I be able to pass my Select
statement into the report?
Thanks.
Nov 15 '05 #1
1 2758
Hi.

One solution is to create a parameter in your Crystal Report (called
'ClientID') and set the properties at runtime in the code before setting the
Report Source, something like:

CrystalReport1 rpt = new CrystalReport1();
ParameterFieldDefinitions paramFieldDefs;
ParamterFieldDefinition paramFieldDef;
ParameterValues paramVal = new ParameterValues();
ParameterDiscreteValues paramDiscreteVal = new ParameterDiscreteValues();

paramDiscreteVal.Value = "4"; // the client id

paramFieldDefs = rpt.DataDefinition.ParameterFields;

paramFieldDef = paramFieldDefs.Item("ClientID");

paramVal = paramFieldDef.CurrentValues;

paramVal.Add(paramDiscreteVal);

paramFieldDef.ApplyCurrentValues(paramVal);

rpt.SetDataSource(DS_MyReportsDS);

crystalReportViewer1.ReportSource = oRpt;

crystalReportViewer1.Refresh();

---
Steven Wood
"JK" <NONE> wrote in message news:%2***************@tk2msftngp13.phx.gbl...
In my win form, I'm trying to display a Crystal report with the data in my
dataset only but, if I follow the steps in this msdn page:

http://msdn.microsoft.com/library/de...tinaviewer.asp
it always displays all the data regardless of the Select statement I run.
Here's my code:

InitializeComponent();
//my code

CrystalReport1 oRpt = new CrystalReport1(); //CrystalReport1.rpt - it
contais 3 fields from table ClientData: clientid, fname, lname

SqlConnection SQLConn = new SqlConnection("Data Source=localhost; Integrated Security=SSPI;" +

"Initial Catalog=invoicing");

string strThisQuery = "select clientid, fname, lname from ClientData where
clientID = 4"; /it returns only one record

SqlDataAdapter MyDataAdapterClients = new SqlDataAdapter (strThisQuery,
SQLConn);

DataSet DS_MyReportsDS = new DataSet();

MyDataAdapterClients.Fill(DS_MyReportsDS, "ClientData");

oRpt.SetDataSource (DS_MyReportsDS);

crystalReportViewer1.ReportSource = oRpt;
It doesn't matter what my Select returns, it'll always display all the data in ClientData. I posted a similar message a few days ago, and someone posted this:
"If it contains the schema of all the columns, the CrystalReportViewer will display all the data in the table regardless of your select." but I really
didn't understand what he meant. How would I be able to pass my Select
statement into the report?
Thanks.

Nov 15 '05 #2

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

Similar topics

2
by: airkart | last post by:
Hello, I've scoured groups and the web, and haven't found a question like mine answered. I'm using Visual Studio 2003 with the Crystal Reports it comes bundled with and SQL Server 2000....
2
by: Rod | last post by:
We've got an old VB6 application we wrote years ago, that we're working on converting parts of, to an ASP.NET application. So far, the work is going well. Now I'm looking at trying to convert...
7
by: TJoker .NET | last post by:
I'm developing an VB.NET Windows Forms application that uses CR for VS.NET (original version shipped with VS.NET 2002 - my VS.NET has the latest SP installed, no SPs for CR). My reports get their...
0
by: Vadim Vulfov | last post by:
My task was to create Crystal Report on ASP.NET page to display different date depending on to textboxes From Date and To Date. I created stored procedure in SQL with two parameters from_date and...
2
by: aldous scotch | last post by:
I designed a Crystal Report .rpt from within Microsoft Development Environment 2003 Version 7.1.3088 (VB .NET IDE). I selected database fields from the left side Field Explorer onto the Details...
0
by: Jeff | last post by:
Help!!! The bitmap I am trying to display in a sample Crystal Report is coming up with much less quality than the original bitmap. I have a 300x300 dpi bitmap file that I want to insert at run...
1
by: cpnet | last post by:
I'm trying to create a Crystal Report based on a strongly-typed DataSet (that I'm populating manually instead of from a database). This is almost working except Crystal seems to always do inner...
6
by: G. Stoynev | last post by:
I can't seem to be able to prevent a Crystal Reports formula to evaluate an expression when the report contains no records to show. Here's the formula (DateTransferred is a DateTime column): ...
0
by: marcellus7 | last post by:
Hows it going everyone. Im pretty new to Crystal Reports, and am in the process of trying to setup my first Crystal Report in my windows app. I am loading data from a DataSet, and am finally getting...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.