473,749 Members | 2,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dyanmic crystal report

18 New Member
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

Expand|Select|Wrap|Line Numbers
  1. protected void Button1_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         ////CrystalReport1 objRpt;
  5.         ////objRpt = new CrystalReport1();
  6.         ReportDocument report = new ReportDocument();
  7.         string reportPath = Server.MapPath("CrystalReport1.rpt");
  8.  
  9.         report.Load(reportPath); 
  10.  
  11.  
  12.         string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  13.             "Data Source=D:\\mayank/db2.mdb";
  14.  
  15.         //Get Select query String and add parameters to the 
  16.         //Crystal report.
  17.         string query = CreateSelectQueryAndParameters();
  18.  
  19.         //if there is no item select, then exit from the method.
  20.         if (!query.Contains("Column"))
  21.         {
  22.             Response.Write("No selection to display!");
  23.             return;
  24.         }
  25.  
  26.         try
  27.         {
  28.             OleDbConnection Conn = new OleDbConnection(connString);
  29.  
  30.             OleDbDataAdapter adepter =
  31.             new OleDbDataAdapter(query, connString);
  32.             DataSet1 Ds = new DataSet1();
  33.  
  34.             adepter.Fill(Ds, "Customer");
  35.             Response.Write(Ds);
  36.             report.SetDataSource(Ds);
  37.             crystalReportViewer1.ReportSource = report;
  38.  
  39.         }
  40.         catch (OleDbException oleEx)
  41.         {
  42.           //  MessageBox.Show(oleEx.Message);
  43.         }
  44.         catch (Exception Ex)
  45.         {
  46.             //MessageBox.Show(Ex.Message);
  47.         }
  48.  
  49.     }
  50.     private string CreateSelectQueryAndParameters()
  51.     {
  52.         ReportDocument reportDocument;
  53.         ParameterFields paramFields;
  54.  
  55.         ParameterField paramField;
  56.         ParameterDiscreteValue paramDiscreteValue;
  57.  
  58.         reportDocument = new ReportDocument();
  59.         paramFields = new ParameterFields();
  60.  
  61.         string query = "SELECT ";
  62.         int columnNo = 0;
  63.  
  64.         if (CheckBox1.Checked)
  65.         {
  66.             columnNo++;
  67.             query = query.Insert(query.Length, "Code as Column" +
  68.             columnNo.ToString());
  69.  
  70.             paramField = new ParameterField();
  71.             paramField.Name = "col" + columnNo.ToString();
  72.             paramDiscreteValue = new ParameterDiscreteValue();
  73.             paramDiscreteValue.Value = "Customer Code";
  74.             paramField.CurrentValues.Add(paramDiscreteValue);
  75.             //Add the paramField to paramFields
  76.             paramFields.Add(paramField);
  77.         }
  78.         if (CheckBox2.Checked)
  79.         {
  80.             columnNo++;
  81.             if (query.Contains("Column"))
  82.             {
  83.                 query = query.Insert(query.Length, ", ");
  84.             }
  85.             query = query.Insert(query.Length, "FirstName as Column" +
  86.             columnNo.ToString());
  87.  
  88.             paramField = new ParameterField();
  89.             paramField.Name = "col" + columnNo.ToString();
  90.             paramDiscreteValue = new ParameterDiscreteValue();
  91.             paramDiscreteValue.Value = "First Name";
  92.             paramField.CurrentValues.Add(paramDiscreteValue);
  93.             //Add the paramField to paramFields
  94.             paramFields.Add(paramField);
  95.         }
  96.         if (CheckBox3.Checked)
  97.         {
  98.             columnNo++; //To determine Column number
  99.             if (query.Contains("Column"))
  100.             {
  101.                 query = query.Insert(query.Length, ", ");
  102.             }
  103.             query = query.Insert(query.Length, "LastName as Column" +
  104.             columnNo.ToString());
  105.  
  106.             paramField = new ParameterField();
  107.             paramField.Name = "col" + columnNo.ToString();
  108.             paramDiscreteValue = new ParameterDiscreteValue();
  109.             paramDiscreteValue.Value = "Last Name";
  110.             paramField.CurrentValues.Add(paramDiscreteValue);
  111.             //Add the paramField to paramFields
  112.             paramFields.Add(paramField);
  113.         }
  114.         if (CheckBox4.Checked)
  115.         {
  116.             columnNo++;
  117.             if (query.Contains("Column"))
  118.             {
  119.                 query = query.Insert(query.Length, ", ");
  120.             }
  121.             query = query.Insert(query.Length, "Address as Column" +
  122.             columnNo.ToString());
  123.  
  124.             paramField = new ParameterField();
  125.             paramField.Name = "col" + columnNo.ToString();
  126.             paramDiscreteValue = new ParameterDiscreteValue();
  127.             paramDiscreteValue.Value = "Address";
  128.             paramField.CurrentValues.Add(paramDiscreteValue);
  129.             //Add the paramField to paramFields
  130.             paramFields.Add(paramField);
  131.         }
  132.  
  133.  
  134.         //if there is any remaining parameter, assign empty value for that 
  135.         //parameter.
  136.         for (int i = columnNo; i < 5; i++)
  137.         {
  138.             columnNo++;
  139.             paramField = new ParameterField();
  140.             paramField.Name = "col" + columnNo.ToString();
  141.             paramDiscreteValue = new ParameterDiscreteValue();
  142.             paramDiscreteValue.Value = "";
  143.             paramField.CurrentValues.Add(paramDiscreteValue);
  144.             //Add the paramField to paramFields
  145.             paramFields.Add(paramField);
  146.         }
  147.  
  148.         crystalReportViewer1.ParameterFieldInfo = paramFields;
  149.  
  150.         query += " FROM Customer";
  151.  
  152.         return query;
  153.     }
it showing no error but crstal report is not generating

plz tel me the solution its very urgent
Jun 16 '09 #1
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?
Jun 16 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
19180
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,
1
7908
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
13
15176
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
0
4493
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...
2
4933
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
1
12176
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
1
3084
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.
0
2271
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...
11
9691
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
8833
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,...
0
9568
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
9389
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
9335
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
8257
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...
1
6801
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 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...
0
4709
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...
1
3320
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
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.