|
You shouldn't requirer too many feilds to make your report. Are you using the formula feilds to put in the Record Selection Formula of Crystal? You could either filter the datasource before you pass it to crystal (recordset or temporary table) and use crystal to just push out all the information or use the record selection formula to just filter your selection datasource.
|
|
|
Thanx agen for your reply... i'll try it as soon as posible. Give u feedback soon. i wana raise another question... How will i design the report during runtime? Wouldn't it affect the fields location on my report? Is crystal reports programmable w/o VB? Can i program crystal the way i can program vb? Thank you so much.
|
|
|
In theory you can build your report entirely in VB. But I haven't personally played with that. If it helps any there is allot of information you can find on the crystal support site http://support.businessobjects.com/documentation/default.asp you might have to do a bit of digging around but I remember seeing some info about runtime report creation on there.
|
|
|
What If I want to send variable value or value of text field ...
rpt.DataDefinition.FormulaFields.Item("MojaKasa").Text = "'myRegister.ToString'"
This my code did not send the value of variable ... it's send exact text "myRegister.ToString"
|
|
|
rpt.DataDefinition.FormulaFields.Item("MojaKasa").Text = "'" & myRegister.ToString & "'"
|
|
|
Hi there ive tried this i have a non connected report file, with 2 formula fields, i have a data set containing a datatable with these 2 field in, when i assign the dataset to the report object, i get an error, Report has no tables.
Anyone got anyideas
|
|
|
Hi for all!
I'm try do the same dynamic crystal report generation, but use Delphi 7 and Crystal 9.0
I have a register of the field and the table to be view in report.
My dinamic CR report can link other tables, so i can create report with all table of my Database.
The user can register which field and table want see in report. At the moment of execution, the generator get the information for the table and create a XML default. This XML default have always the same name and same fields.
Like This.
--> table1.xml
--field1
--field2
--field3
....
--fieldN
--> table2.xml
--field1
--field2
--field3
....
--fieldN
The rpt is prepared to receive this table.
I'm use a formula fields to show the fields.
My problem is link the table. Somewhat table1.field1 = table2.field3.
I can do it, but is FIXED!!! i want to do it DYNAMIC.
Somebody have any idea???
Excuse me by poor english. I'm from Brazil!!
Tank's for all.
|
|
|
Prezado, estou com o mesmo problema e também sou do Brasil. Estou utilizando ASP.NET e Crystal 10... podemos trocar informação caso um dos dois tenha sucesso...
Ats.
Wender
|
|
|
Wender,
Me envia um e-mail para discutirmos melhor!
silvestree@gmail.com
Me passa mais ou menos até que ponto vc conseguiu chegar e quais estão sendo seus problemas. Depois eu faço o mesmo
T+
|
|
|
Hi,
can you please help me if you have found the solution for the problem as I am also stuck in the same kind of situation.
I am trying to create a report genaration tool where reports are generated depending on the parameters or fields chosen by the user. What i want to do is to create reports dynamically, wherein my DATA SOURCE may be ALTERED , depending in the user. It's like a table with N-number of fields.
Same as your problem
|
|
|
Hi,
i used three text boxes for input the data(txtFName.Text, txtLName.Text, txtComment.Text).and when I press the OK button(cmdOk_Click), the web form has to print a hard copy in the default printer and then print the softcopy on the screen. (dynamic reporting using Crystal Reports)
Please follow these steps: but I Used C#.Net (C#.Net, ASP.Net Web Application). (it is working in my machine)
1.) First Create a Dataset. with the expecting table structure.
(For that you should right click on the project name at Solution explorer, then click the "Add new item" and then select the dataset.)
2.)When you are specifying the dataset at the first column you should specify the table name and then specify the field names and data types.
3.)then as above add a new crystal report, At this point select using the report wizad at first pane and statnd at the second pane.
4.)then in the next of the wizard select the last tab called "Creat new connection".
5.) then in the drop down again select ADO.Net (XML) tab. once you select that you can see a small window in that window for the "file path", select the dataset that you have created in the above steps.
6.)The press finish. and in the next step select the table name as your added dataset and move that into the selected tables pane. then press next and in the next pane select the fields that you want display in the report and finally press finish. now you can see the reports with required fields.
7.)then in the web form code window type the following codes.. (This is purely my own coding and name coventions, please make the required changes and run the project.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace SampleDynamicWebReports
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected SampleDynamicWebReports.DataSet1 DataSet1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox txtFName;
protected System.Web.UI.WebControls.TextBox txtLName;
protected System.Web.UI.WebControls.Button cmdOk;
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtComment;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put Customer code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmdOk.Click += new System.EventHandler(this.cmdOk_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private DataSet GetDataSet()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Customer");
dt.Columns.Add("FName");
dt.Columns.Add("LName");
dt.Columns.Add("Comments");
DataRow dr = dt.NewRow();
dr["FName"] = txtFName.Text;
dr["LName"] = txtLName.Text;
dr["Comments"] = txtComment.Text;
dt.Rows.Add(dr);
ds.Tables.Add(dt);
return ds;
}
private void cmdOk_Click(object sender, System.EventArgs e)
{
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.DataSet1 = new SampleDynamicWebReports.DataSet1();
((System.ComponentModel.ISupportInitialize)(this.DataSet1)).BeginInit();
PageMargins margins;
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Customer", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("FName", "FName"),
new System.Data.Common.DataColumnMapping("LName", "LName"),
new System.Data.Common.DataColumnMapping("Comments", "Comments")})});
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO [Customer] (FName, LName, Comments) VALUES (@FName, @LName, @Comments); SELECT FName, LName, Comments FR" +
"OM [Customer]";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FName", System.Data.SqlDbType.VarChar, 50, "FName"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@LName", System.Data.SqlDbType.VarChar, 50, "LName"));
//
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT FName, LName ,Comments FROM [Customer]";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// DataSet1
//
this.DataSet1.DataSetName = "Dataset1";
this.DataSet1.Locale = new System.Globalization.CultureInfo("en-US");
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.DataSet1)).EndInit();
Customers rptObj = new Customers();
//this.sqlDataAdapter1.Fill(this.DataSet1);
//rptObj.SetDataSource(this.DataSet1);
rptObj.SetDataSource(this.GetDataSet());
margins = rptObj.PrintOptions.PageMargins;
margins.bottomMargin = 500;
margins.leftMargin = 500;
margins.rightMargin = 500;
margins.topMargin = 500;
// Apply the page margins.
rptObj.PrintOptions.ApplyPageMargins(margins);
rptObj.PrintOptions.PrinterName = "Canon LASER SHOT LBP-1120";
//rptObj.PrintOptions.PrinterName = @"\\192.168.1.125\Canon LASER SHOT LBP-1120";
rptObj.PrintToPrinter(1,false,0,0);
this.CrystalReportViewer1.ReportSource = rptObj;
}
}
}
Thanks,
Jey
|
|
|
Hi,
i used three text boxes for input the data(txtFName.Text, txtLName.Text, txtComment.Text).and when I press the OK button(cmdOk_Click), the web form has to print a hard copy in the default printer and then print the softcopy on the screen. (dynamic reporting using Crystal Reports)
Please follow these steps: but I Used C#.Net (C#.Net, ASP.Net Web Application). (it is working in my machine)
1.) First Create a Dataset. with the expecting table structure.
(For that you should right click on the project name at Solution explorer, then click the "Add new item" and then select the dataset.)
2.)When you are specifying the dataset at the first column you should specify the table name and then specify the field names and data types.
3.)then as above add a new crystal report, At this point select using the report wizad at first pane and statnd at the second pane.
4.)then in the next of the wizard select the last tab called "Creat new connection".
5.) then in the drop down again select ADO.Net (XML) tab. once you select that you can see a small window in that window for the "file path", select the dataset that you have created in the above steps.
6.)The press finish. and in the next step select the table name as your added dataset and move that into the selected tables pane. then press next and in the next pane select the fields that you want display in the report and finally press finish. now you can see the reports with required fields.
7.)then in the web form code window type the following codes.. (This is purely my own coding and name coventions, please make the required changes and run the project.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace SampleDynamicWebReports
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected SampleDynamicWebReports.DataSet1 DataSet1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox txtFName;
protected System.Web.UI.WebControls.TextBox txtLName;
protected System.Web.UI.WebControls.Button cmdOk;
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtComment;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put Customer code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmdOk.Click += new System.EventHandler(this.cmdOk_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private DataSet GetDataSet()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Customer");
dt.Columns.Add("FName");
dt.Columns.Add("LName");
dt.Columns.Add("Comments");
DataRow dr = dt.NewRow();
dr["FName"] = txtFName.Text;
dr["LName"] = txtLName.Text;
dr["Comments"] = txtComment.Text;
dt.Rows.Add(dr);
ds.Tables.Add(dt);
return ds;
}
private void cmdOk_Click(object sender, System.EventArgs e)
{
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.DataSet1 = new SampleDynamicWebReports.DataSet1();
((System.ComponentModel.ISupportInitialize)(this.DataSet1)).BeginInit();
PageMargins margins;
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Customer", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("FName", "FName"),
new System.Data.Common.DataColumnMapping("LName", "LName"),
new System.Data.Common.DataColumnMapping("Comments", "Comments")})});
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO [Customer] (FName, LName, Comments) VALUES (@FName, @LName, @Comments); SELECT FName, LName, Comments FR" +
"OM [Customer]";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FName", System.Data.SqlDbType.VarChar, 50, "FName"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@LName", System.Data.SqlDbType.VarChar, 50, "LName"));
//
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT FName, LName ,Comments FROM [Customer]";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// DataSet1
//
this.DataSet1.DataSetName = "Dataset1";
this.DataSet1.Locale = new System.Globalization.CultureInfo("en-US");
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.DataSet1)).EndInit();
Customers rptObj = new Customers();
//this.sqlDataAdapter1.Fill(this.DataSet1);
//rptObj.SetDataSource(this.DataSet1);
rptObj.SetDataSource(this.GetDataSet());
margins = rptObj.PrintOptions.PageMargins;
margins.bottomMargin = 500;
margins.leftMargin = 500;
margins.rightMargin = 500;
margins.topMargin = 500;
// Apply the page margins.
rptObj.PrintOptions.ApplyPageMargins(margins);
rptObj.PrintOptions.PrinterName = "Canon LASER SHOT LBP-1120";
//rptObj.PrintOptions.PrinterName = @"\\192.168.1.125\Canon LASER SHOT LBP-1120";
rptObj.PrintToPrinter(1,false,0,0);
this.CrystalReportViewer1.ReportSource = rptObj;
}
}
}
Thanks,
Jey
|
|
|
Hi all,
I have gone through all the replies discussed here for the topic. I have few more queries about the same. Here we have discussed that we can mention the DataTable columns for the dynamic report. But, they are mapped to the specific table in the Database. Is it possible to display various fields based on the user input, which is going to mention only the fields to be displayed on the report based on the various criteria. In this case we are not aware of the no. of columns of the report. Also, Group By, Order By can be used for such dynamic report? As per the discussion many of us have used the FomulaFields to display the report. Can we use it to satisfy this kind of dynamic report using Crystal Reports?
Thanks & Regards,
Dipali.
|
|
|
Hi Dipali,
I think you didn't go through my code fully (May be it is too long), Anyway what I have mentioned there was, just printing the reports using user inputs. Inorder to generate the report(template) only I am using a temporary dataset. Once if you generate a report even if you want you can dispose that dataset and you could assign a new dataset with the same field names and you could pass the parameters dynmically (Using some input controls).
rptObj.SetDataSource(this.getDataSet());
this.CrystalReportViewer1.ReportSource = rptObj;
under getDataSet method you could specify the dataset that you are sending dynamically. If you need some more help don't hesitate to ask.
|
|
|
Hi Jey,
Thanks for your immediate reply. I know the ususal way where we go for reporting tools mostly in the situations where we know the columns of my report and mostly we send the parameters to filter the data of report. The thing which I am looking for is: "To generate the report at run-time where all the fields of report will be known at run-time only. So, I do not have any fix format for the report at design time. All the "WHERE clause" conditions will also be dynamic. I just wanted to know whether Crystal Reports can satisfy this requirement or if any other reporting tool can! You seems quite experienced in using them. So, if any idea whether it's possible or not at all possible...pls. let me know.
Thanks & Regards,
Dipali.
|
|
This 42 message thread spans 3 pages: < < 1 [2] 3 > > |
|
|
|
|
|