hi guys i wan to make dyanmic crystal report according to values which i checked from check box
thats all i did
1. I made data set having data table name "Customer"
2 i put four columm id,name
,age ,sex
3. then i made crystal report and drag those columm in crystal report
4 thn i drag crystal report viwer
5 thn i write tht code at button click - protected void Button1_Click(object sender, EventArgs e)
-
{
-
-
////CrystalReport1 objRpt;
-
////objRpt = new CrystalReport1();
-
ReportDocument report = new ReportDocument();
-
string reportPath = Server.MapPath("CrystalReport1.rpt");
-
-
report.Load(reportPath);
-
-
-
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
-
"Data Source=D:\\mayank/db2.mdb";
-
-
//Get Select query String and add parameters to the
-
//Crystal report.
-
string query = CreateSelectQueryAndParameters();
-
-
//if there is no item select, then exit from the method.
-
if (!query.Contains("Column"))
-
{
-
Response.Write("No selection to display!");
-
return;
-
}
-
-
try
-
{
-
OleDbConnection Conn = new OleDbConnection(connString);
-
-
OleDbDataAdapter adepter =
-
new OleDbDataAdapter(query, connString);
-
DataSet1 Ds = new DataSet1();
-
-
adepter.Fill(Ds, "Customer");
-
Response.Write(Ds);
-
report.SetDataSource(Ds);
-
crystalReportViewer1.ReportSource = report;
-
-
}
-
catch (OleDbException oleEx)
-
{
-
// MessageBox.Show(oleEx.Message);
-
}
-
catch (Exception Ex)
-
{
-
//MessageBox.Show(Ex.Message);
-
}
-
-
}
-
private string CreateSelectQueryAndParameters()
-
{
-
ReportDocument reportDocument;
-
ParameterFields paramFields;
-
-
ParameterField paramField;
-
ParameterDiscreteValue paramDiscreteValue;
-
-
reportDocument = new ReportDocument();
-
paramFields = new ParameterFields();
-
-
string query = "SELECT ";
-
int columnNo = 0;
-
-
if (CheckBox1.Checked)
-
{
-
columnNo++;
-
query = query.Insert(query.Length, "Code as Column" +
-
columnNo.ToString());
-
-
paramField = new ParameterField();
-
paramField.Name = "col" + columnNo.ToString();
-
paramDiscreteValue = new ParameterDiscreteValue();
-
paramDiscreteValue.Value = "Customer Code";
-
paramField.CurrentValues.Add(paramDiscreteValue);
-
//Add the paramField to paramFields
-
paramFields.Add(paramField);
-
}
-
if (CheckBox2.Checked)
-
{
-
columnNo++;
-
if (query.Contains("Column"))
-
{
-
query = query.Insert(query.Length, ", ");
-
}
-
query = query.Insert(query.Length, "FirstName as Column" +
-
columnNo.ToString());
-
-
paramField = new ParameterField();
-
paramField.Name = "col" + columnNo.ToString();
-
paramDiscreteValue = new ParameterDiscreteValue();
-
paramDiscreteValue.Value = "First Name";
-
paramField.CurrentValues.Add(paramDiscreteValue);
-
//Add the paramField to paramFields
-
paramFields.Add(paramField);
-
}
-
if (CheckBox3.Checked)
-
{
-
columnNo++; //To determine Column number
-
if (query.Contains("Column"))
-
{
-
query = query.Insert(query.Length, ", ");
-
}
-
query = query.Insert(query.Length, "LastName as Column" +
-
columnNo.ToString());
-
-
paramField = new ParameterField();
-
paramField.Name = "col" + columnNo.ToString();
-
paramDiscreteValue = new ParameterDiscreteValue();
-
paramDiscreteValue.Value = "Last Name";
-
paramField.CurrentValues.Add(paramDiscreteValue);
-
//Add the paramField to paramFields
-
paramFields.Add(paramField);
-
}
-
if (CheckBox4.Checked)
-
{
-
columnNo++;
-
if (query.Contains("Column"))
-
{
-
query = query.Insert(query.Length, ", ");
-
}
-
query = query.Insert(query.Length, "Address as Column" +
-
columnNo.ToString());
-
-
paramField = new ParameterField();
-
paramField.Name = "col" + columnNo.ToString();
-
paramDiscreteValue = new ParameterDiscreteValue();
-
paramDiscreteValue.Value = "Address";
-
paramField.CurrentValues.Add(paramDiscreteValue);
-
//Add the paramField to paramFields
-
paramFields.Add(paramField);
-
}
-
-
-
//if there is any remaining parameter, assign empty value for that
-
//parameter.
-
for (int i = columnNo; i < 5; i++)
-
{
-
columnNo++;
-
paramField = new ParameterField();
-
paramField.Name = "col" + columnNo.ToString();
-
paramDiscreteValue = new ParameterDiscreteValue();
-
paramDiscreteValue.Value = "";
-
paramField.CurrentValues.Add(paramDiscreteValue);
-
//Add the paramField to paramFields
-
paramFields.Add(paramField);
-
}
-
-
crystalReportViewer1.ParameterFieldInfo = paramFields;
-
-
query += " FROM Customer";
-
-
return query;
-
}
it showing no error but crstal report is not generating
plz tel me the solution its very urgent
1 2314 tlhintoq 3,525
Recognized Expert Specialist
Have you done the basic debugging?
Put a breakpoint at line 6 and walk through the code one line at a time to see - where it is not behaving as you expect.
- Confirm that *every* value is valid along the way (paths, assumptions etc.)
- Are you sure you have permission to write to the destination servers/volumes?
- Maybe you're getting exceptions and not seeing them since your messageboxes are commented out.
- Confirmed that each query going out is right, and each response back is right and has content?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 Report at runtime?
Example:
private void button1_Click(object sender,
|
by: Chris Neal |
last post by:
I recenetly purchased VB.net standard and in the box was
a card saying that it included crystal reports (as it
always used to) but I cannot find CR in the templates or
in the toolbox. Can anyone tell me where I can download
it, or how I might install it if it is already there.
Thanks
|
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
designer it shows up very fast. When the report
is printed from my application it takes about
ten times as long to get the report to appear.
When printing straight from the Crystal Reports
|
by: Dr. Indera |
last post by:
hello,
i previously posted the questions below on several crystal reports newsgroups, including the one for
the company that makes crystal reports, but never got an answer, so i'm hoping that someone on this
board knows the answers to them. the questions are for the version of crystal that ships with visual
studio.net 2003. if it helps, the reports that i create are in a visual basic.net project. it was
recommended that i post the...
|
by: Mythran |
last post by:
In .Net, how can I go about and set a Crystal Reports namespace? Right now
they use the Root Namespace (VB) from the project. How can I extend the
namespace for a single report (which will be set on all reports)?
Thanks for any and all help, in advance :)
Mythran
| |
by: Karthic |
last post by:
When i right click on the .rpt file in the VS 2003, i see a property
printer setting.
It says "No printer" on the top and there is option to select printer
and paper settings etc..
I want to know how will this affect a report rendered by a crystal
viewer.
I have a web page with a crystal viewer rendering the report on the
page.
I build my application in one of my development machines and deploy it
|
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 CrystalKeyCodeLib, or one of its dependencies,
was not found."
I read that the 4 MSM files need to be moved to the a MERGE MODULES
folder in the Common Files folder, but didn't seem to do a thing.
|
by: Chris |
last post by:
I have the following situation in a VB.Net App I am working on:
1.)A report created in VS.Net 2003 using the CR.Net component of VS 2003.
2.)The datasource for the report is a Stored Proc in a SQL Server DB (pull
method).
3.)The Stored Proc has two input parameters of type date.
4.)The Stored Proc is a rather complex proc that was not written by me, but
does work(see next item). It currently returns about 13K rows of data.
5.)The...
|
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
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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,...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |