473,602 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

InitializeCompo nent();
//my code

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

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

"Initial Catalog=invoici ng");

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

SqlDataAdapter MyDataAdapterCl ients = new SqlDataAdapter (strThisQuery,
SQLConn);

DataSet DS_MyReportsDS = new DataSet();

MyDataAdapterCl ients.Fill(DS_M yReportsDS, "ClientData ");

oRpt.SetDataSou rce (DS_MyReportsDS );

crystalReportVi ewer1.ReportSou rce = 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 CrystalReportVi ewer 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 2773
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( );
ParameterFieldD efinitions paramFieldDefs;
ParamterFieldDe finition paramFieldDef;
ParameterValues paramVal = new ParameterValues ();
ParameterDiscre teValues paramDiscreteVa l = new ParameterDiscre teValues();

paramDiscreteVa l.Value = "4"; // the client id

paramFieldDefs = rpt.DataDefinit ion.ParameterFi elds;

paramFieldDef = paramFieldDefs. Item("ClientID" );

paramVal = paramFieldDef.C urrentValues;

paramVal.Add(pa ramDiscreteVal) ;

paramFieldDef.A pplyCurrentValu es(paramVal);

rpt.SetDataSour ce(DS_MyReports DS);

crystalReportVi ewer1.ReportSou rce = oRpt;

crystalReportVi ewer1.Refresh() ;

---
Steven Wood
"JK" <NONE> wrote in message news:%2******** *******@tk2msft ngp13.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:

InitializeCompo nent();
//my code

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

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

"Initial Catalog=invoici ng");

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

SqlDataAdapter MyDataAdapterCl ients = new SqlDataAdapter (strThisQuery,
SQLConn);

DataSet DS_MyReportsDS = new DataSet();

MyDataAdapterCl ients.Fill(DS_M yReportsDS, "ClientData ");

oRpt.SetDataSou rce (DS_MyReportsDS );

crystalReportVi ewer1.ReportSou rce = 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 CrystalReportVi ewer 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
1253
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. Throughout the project I'm working on, I often find I need a temporary table displayed in a report, something that I cannot seem to do. Since temporary tables are so useful, I cannot imagine Crystal Reports wouldn't have a way to get such
2
1732
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 the Crystal Reports to the new system. To use the terminology that Crystal uses, the old VB6 application used a "pull" methodology, meaning that the stored procedure was specified within the .RPT file, and parameters were all there, and when you...
7
34772
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 data from ADO.NET Datasets that are pre-populated by other modules of the application. What I need to do is to use these datasets as the datasources of my reports. Fine, I know how to do that and it works perfectly on my development box. The...
0
1275
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 to_date. I created dataset object in ASP.NET (drag and drop on it the stored procedure I just created) and save as XSD file. In the Crystal Report selected all the fields and included into the
2
3063
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 (Section3) of the .rpt. Also, I added a new web form myWebform.aspx and a web object CystalReportViewer - CrystalReportViewer1 and had a code behind in ReportSource
0
7407
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 time into a Crystal Report. The path to the file is stored in a varchar(100) field in a table in SQL Server. The Crystal Report displays the bitmap in the IBlobField object but it
1
1831
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 joins along the relationships in the DataSet, but I want an outer join. I have a table (QuestionTable) that's a list of questions. Each row contains the question, as well as the foreign key to a row in AnswerTable (which contains the...
6
6579
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): If IsNull({MyReportDataSet.DateTransferred}) Then " " //empty string Else If ({MyReportDataSet.DateTransferred} = CDate("1/1/1900")) Then " " //also pring an empty string - 1/1/1900 means "no date was
0
1507
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 all the data loaded correctly, but the problem is it just keeps repeating the details section. I have 5 sub reports, each with their own table of data from which to get data. The report is generated correctly, but it just continuously is repeating...
0
7993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.