|
I had a hairy SQL statement which I would never be able to build with CR, the last resort was to code the report by hand until I sussed the SetDataSource method, the glue missing was the XML schema which I needed to create, once that was done, it worked like a charm. Thanks for the aricle.
My Blog ^
|
|
|
|
|
CrystalReport1 report=new CrystalReport1();
CrystalReportViewer1.Visible=true;
report.SetDataSource(Ds.Tables[0]);
CrystalReportViewer1.ReportSource = report;
I have above code to fill report, when i run first time it did not fill the report. I went to solution and create a CR report. Connect the database from server explorer and get the table and drag the col that i want on the report. and worked fine.
If i do this whats do use of the DS. How DS releated to the report. Is this the way doing this. My DS already have the data. How come its not showing with out plugging the data from server solution.
Am i doing this wrong. seems like there is two connection and tow data.
DS and report
is this the way to do push?
|
|
|
|
|
How to connect crystal report file in ASP.Net using C# language during runtime to generate the report
|
|
|
|
|
This would seem to be straightforward but is not (for me at least!) I'm creating a report in a separate *aspx page, and the display is always centered (or more toward the far right of the page. I want to have the display left justified .... have tried on the page holding the crystal report viewer, putting review control in table, going through the .Net crystal report form, all to no avail.
|
|
|
|
|
Will you be using the Group Tree option? Your report appears to be centered because the group tree is blank.
If you will not be needing this,
just set your Viewer's(CrystalReportViewer) DisplayGroupTree to false.
G'luck!
kRoN
|
|
|
|
|
hi any example of using a crystal report in asp.net, using the northwind table of sql... thnx...
|
|
|
|
|
Visual Studio 2003 / SQL 2005 Beta
For some reason I can not use the GUI to create dataset from my stored procedure. It may be because I have multiple selects or it may be SQL 2005. In any case, I must code my dataset by hand. Once done I would think that it would be easy to point my crystal report at this dataset. It not though. I am getting a Logon failed error. If I omit all code and just run the function that creates the dataset I get no error. When should I have a security issue binding the report to a dataset that is in .NET already? Does anyone see anyting wrong with this code?
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace ptr
{
///
/// Summary description for availToActualHoursDS.
///
public class availToActualHoursDS : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
availToActualHoursCR MyReport = new availToActualHoursCR();
CrystalReportViewer1.Visible=true;
// get Logon failed error with and without this code.
CrystalDecisions.Shared.TableLogOnInfo MyLogonInfo;
CrystalReportViewer1.LogOnInfo = new CrystalDecisions.Shared.TableLogOnInfos();
MyLogonInfo = new CrystalDecisions.Shared.TableLogOnInfo();
MyLogonInfo.TableName="MyReport";
MyLogonInfo.ConnectionInfo.UserID = "reporting";
MyLogonInfo.ConnectionInfo.Password = "password";
MyLogonInfo.ConnectionInfo.DatabaseName = "nyce";
CrystalReportViewer1.LogOnInfo.Add(MyLogonInfo);
// set report's dataset
MyReport.SetDataSource(CreateATAHDataSet(2003, 8, 2004, 7, "55200,55300"));
// set report source
CrystalReportViewer1.ReportSource = MyReport;
}
// create a dataset for the cyrstal report to report off of
private DataSet CreateATAHDataSet(int startyearpart, int startmonthpart, int endyearpart, int endmonthpart, string ccntrs)
{
//11-16 Prog ASP.NET - Stored Procedures
string connectionString = "server=cfaulkner; uid=reporting; pwd=password; database=NYCE";
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString);
connection.Open();
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
command.Connection = connection;
command.CommandText = "sp_rpt_EmpHrsAvailToActualHrsByMonth";
command.CommandType = CommandType.StoredProcedure;
System.Data.SqlClient.SqlParameter param;
param = command.Parameters.Add("@startyearpart", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = startyearpart;
param = command.Parameters.Add("@startmonthpart", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = startmonthpart;
param = command.Parameters.Add("@endyearpart", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = endyearpart;
param = command.Parameters.Add("@endmonthpart", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = endmonthpart;
param = command.Parameters.Add("@ccntrs", SqlDbType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = ccntrs;
SqlDataAdapter dataAdapter = new SqlDataAdapter();
dataAdapter.SelectCommand = command;
dataAdapter.TableMappings.Add("Table", "ATAH");
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}
#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);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
Thanks for ANY help! I have been racking my brain for days on this.
Craig
|
|
|
|
|
Keep racking your brain. That error message could be just about anything. I've had it too, dunno what solved it but I'm carefull not to touch the reports to much or I'm afraid i get it again.
I have just spend 15 hours infront of Crystal Reports. I have spent 2 month solving different problems working more the full time, weekends. When I pass one another one shows up and I'm back where I started. I have read books, installed updates (those are a joke btw.), if I get something to work there is allways ten other things that isn't.
Today I'm giving up. I am so f***ing tired of this. I finally decided to go with the most simples and basic solution of all. I decided to create one single table for each of the reports that I'm doing. One of the tables has around 800-900 columns. This is a solution that works. So I started to put all the fields out on the reports and then I realised that the designer can't keep the positions and sizes of the elements.
I have lost sooo many hours on this, it's not even funny anymore. I'm a developer, I have written code since I was 13 and I have gone through much problem solving. But working with Crystal Repors cost me all my love for developing.
I'm giving up.. bye bye coding and computers
----------------
Frasse
|
|
|
|
|
If the report having a sub report, how can I do? How to push the dataset into the sub-report. Thanks.
|
|
|
|
|
This is a great article for anyone who wants to learn how to create reports with Crystal Reports, as I did with this simple and great article.
Since then however, I have developed a deep hate towards Crystal Reports.
Even thou I have never made such statement in public before, I can just say how glad I am to get this off my chest. Because the only thing this product have given me the last month or so is sorrow and nervous breakdowns. If I was living in the US, I would sue the muther f***er who is responsible for this software.
My advice to any of you who even consider doing any report that requires more then five bindings to a single datatable, for your own sanity sake do not use Crystal Reports. For small applications like the one used in this tutorial you may even like it.
I stand by my statement, feel free to flame me but I doubt anyone will because I beleive that there are alot of peoples out there that need counceling after they have used this frustrating tool.
--------------------------------------------------------------
This is where you send your flames: Fredrik Andersson
|
|
|
|
|
Hello ,
I make SeparatePages property of crystal viewer false. So that all crystal report pages appear in one asp.net page. But what happens is, my page design shows only for one page hight and the content goes beyond page design. So basically content does not fit into the asp.net page at run time.
What can be the solution of this problem.
Please let me know if you want more information.
Best Regards
|
|
|
|
|
Hi,
Can anyone provide the solution for following error.
CrystalDecisions.CrystalReports.Engine.DataSourceException: Query Engine Error:
Some of the reports are displayed properly. For some it's giving this error.
Order and type of parameters passed are just perfect and so is the location of report.
I dont know where's the problem..
Plz reply asap.
Thanks in anticipation
|
|
|
|
|
Using pull method i can display the image in the crystal report. this can be done by using the subreport.
But when we are using the push method, how is it possible to use sub report ...?
or is there any other method by which i can display the image on the report.
Regards,
Sandeep Patel
|
|
|
|
|
When i am using one datasource, the reports are working fine ... but i want to use 2 datatables.... is it possible..
sqlConn = New SqlConnection(ConnString)
Dim strSql As String
sqlcommd = New SqlCommand
' sqlcommd.Parameters.Add("@quantity", TextBox2.Text)
sqlcommd.Parameters.Add("@EmployeeID", TextBox1.Text)
sqlcommd.CommandText = "USP_Report"
sqlcommd.CommandType = CommandType.StoredProcedure
sqlcommd.Connection = sqlConn
daObj = New SqlDataAdapter
daObj.SelectCommand = sqlcommd
dsObj = New DataSet
daObj.Fill(dsObj, "Emp")
crpt.Visible = True
cr.Load(Server.MapPath("crpt.rpt"))
cr.SetDataSource(dsObj.Tables("Emp"))
cr.SetDataSource(dsObj.Tables("orders"))----- can this be added
crpt.ReportSource = cr
Regards,
Sandeep Patel
|
|
|
|
|
I was bulid a project buy following this mothed. however, I get a error..
please help me out.
----------------------------------------------------
Error in File C:\DOCUME~1\TEPC402\ASPNET\LOCALS~1\Temp\temp_198f502c-275c-44a1-88a4-89a648a75696.rpt: Unable to connect: incorrect log on parameters.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Error in File C:\DOCUME~1\TEPC402\ASPNET\LOCALS~1\Temp\temp_198f502c-275c-44a1-88a4-89a648a75696.rpt: Unable to connect: incorrect log on parameters.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[LogOnException: Error in File C:\DOCUME~1\TEPC402\ASPNET\LOCALS~1\Temp\temp_198f502c-275c-44a1-88a4-89a648a75696.rpt:
Unable to connect: incorrect log on parameters.]
.L(String , EngineExceptionErrorID )
.G(Int16
, Int32 )
.F(Int16 )
CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext)
CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext)
CrystalDecisions.Web.ReportAgent.{(Boolean C)
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e)
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Page.ProcessRequestMain()
nan
|
|
|
|
|
This is another Crystal Reports Bug... install last service pack... from this location
http://support.businessobjects.com/fix/downloads_updates.asp
|
|
|
|
|
How can I read ahead in the database... I need to get integer values from the database several rows below the current row that crystal reports is on
|
|
|
|
|
may want to mention that I am using Crystal Reports .NET (~CR9) in VS.NET 2003. THe database is stored inside a dataset. The database itself is a MS Sql db
|
|
|
|
|
How to print Crystal Reports in Web-Based application??
I was born intelligent Education ruined me!.
|
|
|
|
|
This code can help u print the report
Private Sub lnkPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkPrint.Click
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim strFileName As String
Try
' Create temporary file to send it to the client
strFileName = Request.PhysicalApplicationPath + "Exported\"
If Directory.Exists(strFileName) = False Then
Directory.CreateDirectory(strFileName)
End If
strFileName = strFileName + Session.SessionID.ToString & ".pdf"
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = strFileName
crExportOptions = RptDoc.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
RptDoc.PrintOptions.PaperOrientation = PaperOrientation.Landscape
RptDoc.Export()
' The following code writes the pdf file to the Clients browser.
Response.Clear()
Response.ClearContent()
'Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(strFileName)
Response.Flush()
Response.Close()
' delete the exported file from disk
System.IO.File.Delete(strFileName)
Catch ex As Exception
HandleException(ex, Err.RptPrintFailed)
End Try
End Sub
Regards,
Sandeep Patel
|
|
|
|
|
Dear Sandhep patel,
Where the reference "ExportOptions" come from ?
thx
|
|
|
|
|
Add this to ur code
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Problem will be solved...
Regards,
SAndeep
|
|
|
|
|
Directory not declared
what is rptdoc????
Actually i am exporting crystal report to pdf but it is show an following error during export
Error in File C:\WINDOWS\TEMP\temp_d0912936-dbb3-4b2f-a54c-b63bf29cccd9.rpt: Operation not yet implemented.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Error in File C:\WINDOWS\TEMP\temp_d0912936-dbb3-4b2f-a54c-b63bf29cccd9.rpt: Operation not yet implemented.
Source Error:
Line 197: DiskOpts.DiskFileName = strFilePath
Line 198: rpt.ExportOptions.DestinationOptions = DiskOpts
Line 199: rpt.Export()
Line 200: obj1JavaScriptClass.OpenPDFFile(Me, "Output.pdf")
Line 201:
|
|
|
|
|
When I saw the header of this article I thought it may help me with the functionality i'm looking for.
I'm going to create a report at runtime, let the user select a bunch of fields, create the dataset on the fly and pass it to the report and show it. Sounds simple doesn't it?
/Håkan N.
------------------------------------------------
- Bachelor in systems analysis 1991
- Systems developer, C#, Java, C, VB3-6
- DBA, database design, SQL, admin
------------------------------------------------
|
|
|
|
|
Hi. I'm using VS.NET 2002 and RAS to make some reports. I want to use the push method to implement these reports.
But when I am trying to push a dataset that has a image column into crystal report, an error always displays:
"System.ArgumentException: Type System.Byte[] can not be marshaled as an
unmanaged structure; no meaningful size or offset can be computed"
It almost makes me mad,I don't know how to resolve this problem!
Pls help me! Thanks!
|
|
|
|