i already went through the following questions.please don't mark as duplicate to my question. https://stackoverflow.com/questions/24432683/crystal-report-is-not-showing-data-after-some-time-in-cr-version-13-0-2000-0
I am facing this issue since last 1 month.My crystal report are working fine development environment (windows-7 32bit,VS2010,Crystal report V.13). I deployed on server (windows server-2012 64bit,core i5 ). Problem is that after some time report getting blank.I search a lot about that and use Dispose(),Close() method,right now I m using the following code.
public static void OpenPdfInBrowser(ReportClass RptReport)
{
string strFilename;
string strFolderName;
string strFile = String.Empty;
string strReportOutputName = String.Empty;
HttpResponse objResponse = HttpContext.Current.Response;
HttpSessionState objSession = HttpContext.Current.Session;
HttpServerUtility objServer = HttpContext.Current.Server;
strFolderName = objServer.MapPath("../ReportOutput");
if (Directory.Exists(strFolderName) == false)
{
Directory.CreateDirectory(strFolderName);
}
//Generate the File Name
strFilename = "";
strFile = objSession.SessionID.ToString() + "_" + DateTime.Now.Ticks.ToString() + ".pdf";
strFilename = strFolderName + "\\" + strFile;
//Set the File Name
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
diskOpts.DiskFileName = strFilename;
//Set the Various Options
ExportOptions exportOpts = new ExportOptions();
exportOpts = RptReport.ExportOptions;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
exportOpts.DestinationOptions = diskOpts;
//Export the Report
RptReport.Export();
//Stream it to the Client
objResponse.ClearContent();
objResponse.ClearHeaders();
strReportOutputName = "Report";
objResponse.ContentType = "application/pdf";
objResponse.AddHeader("Content-Disposition", "inline;filename=Report.pdf");
objResponse.WriteFile(strFilename);
objResponse.Flush();
objResponse.Close();
//Delete the File
System.IO.File.Delete(strFilename);
//Close the Report Object
RptReport.Close();
RptReport.Dispose();
GC.Collect();
}
I am getting the following error in event viewer on deployment server.
The description for Event ID 4353 from source Crystal Reports cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
The keycode assembly, BusinessObjects.Licensing.KeycodeDecoder.dll, cannot be loaded.
Any help will be greatly appreciated. thanks in adnvace.
Copy your asp.net folder to server virtual directory...
Not sure but hope ur problem will resolve. Best Luck.
The issues is looking like, related to the Crystal report installation on the server... If its working fine on the Development Machine and if All the applications required to run the crystal reports are installed on the Deployment server, then please, check.. Application Pool in IIS --> select the Application Pool used for the Web applicaiton --> Advanced Settings-> Enable 32-Applications --> Set this to "True" ..
Please, try and check...
After a long research my problem has been resolved by doing following changes in registry.Actually this issue is related to Print Job Limit which by default 75 I just extend its data size according to my requirement and it work for me.
Go to-->RUN----->Regedit
1-HKEY_LOCAL_MACHINE
2-SOFTWARE
3-SAP BUSINESS OBJECT
4-CRYSTAL REPORT FOR .NET FRAMEWORK(your version no.)
5-REPORT APPLICATION SERVER
6-SERVER
then got to "PrintJobLimit" PROPERTY and change its Data size to whatever you want.
thanks for every one who help me in this
Your approach is correct to use .close and . dispose but the best way to use it is :
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
cryRpt.Close()
cryRpt.Dispose()
End Sub
to open crystal report in PDF you can use http response it will be better in performance :
cryRpt = New ReportDocument
cryRpt.Load(Server.MapPath("Your report path"))
cryRpt.SetDataSource(Your data source)
cryRpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "ExportedReport")
Related
I wrote an application to help users generate letters using C#. I have templates created that are saved in the SQL Server database as rich text. My development machine is Windows 7 and I use Visual Studio 2019 to code the application. I used NuGet to add the interop reference for Word. The application is configured for Release, platform Active(Any CPU), targeting x86. It is a ClickOnce application that is installed from a share drive in a separate directory but the same drive on which the letters are saved.
The application runs properly from my machine but not from a Windows 10 user machine. When it tries to save the file, she gets an error that says "sorry we couldn't find the file". We both have Word 2016. Both machines are 64 bit. I save the letter as a backup in Word and then export to PDF. The code fails on saving the Word document, before the export to PDF. Please see code snippet below:
public static void SaveToWord2(string CoverLetter, string LetterText, string FileSave,
string BackUpSave, ref string ErrorString)
{
try
{
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
string HeaderFooterFile = Properties.FileResources.HeaderFooterTemplate;
Document oDoc = new Document();
oDoc = oWord.Documents.Add(#HeaderFooterFile);
oDoc.Activate();
try
{
Clipboard.Clear();
Clipboard.SetText(CoverLetter, TextDataFormat.Rtf);
oDoc.ActiveWindow.Selection.Paste();
Clipboard.Clear();
Clipboard.SetText(LetterText, TextDataFormat.Rtf);
oDoc.ActiveWindow.Selection.Paste();
//01/26/2021 JS having trouble with the save on Pam's machine so going to try to capture the correct error.
try
{
oDoc.SaveAs(#BackUpSave);
}
catch (Exception exBU)
{
ErrorString = "Error trying to save " + #BackUpSave + ": " + exBU.Message;
}
try
{
oDoc.ExportAsFixedFormat(#FileSave, WdExportFormat.wdExportFormatPDF);
}
catch (Exception exPDF)
{
if (string.IsNullOrEmpty(ErrorString))
{
ErrorString = "Error trying to save " + #FileSave + " PDF: " + exPDF.Message;
}
else
{
ErrorString += " and Error trying to save " + #FileSave + " PDF: " + exPDF.Message;
}
}
}
catch (Exception exInner)
{
ErrorString = exInner.Message;
MessageBox.Show(exInner.Message, Properties.LetterResources.SaveToWord, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Clipboard.Clear();
oWord.Quit(SaveChanges: 0);
Marshal.FinalReleaseComObject(oWord);
//oWord.Visible = true;
}
catch (Exception ex)
{
ErrorString = ex.Message;
MessageBox.Show(ex.Message, Properties.LetterResources.SaveToWord, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
The error is occurring on the oDoc.SaveAs line but only when running from a Windows 10 computer. Originally, I used the interop from my machine but then changed it to the NuGet interop but that didn't fix the problem. I tried changing Embed Interop Types to False but that didn't fix anything so I changed it back. The Aliases property of the interop reference is global and the Specific Version property is True. I am worried about changing the type of document writer because of the rich text. The rest of the application is working fine for the Windows 10 user. Any ideas?
OpenXML did not work out as it would not allow me to properly add headers correctly or export to PDF. I ended up returning to the Word Interop even though I very badly would have liked to use OpenXML. I was able to resolve the problem by setting the reference properties as follows:
Embed Interop Types = False
Copy Local = True
Now the save works no matter which operating system runs the program. I had part of the answer above, but neglected the Copy Local = true piece.
I am trying to set a given RDL report to use an embedded data source using my client application. I am using the ReportingService2005 class to interact with SSRS. I need to set the embedded data source to use "Credentials stored securely in the report server" and specify the username and password.
Thank you!
I solved the issue by first publishing the RDL, then calling into the ReportingService2005 GetItemDataSources() method. I then modified that datasource and subsequently called SetItemDataSources() to save the changes into SSRS. Below is a snippet of the code I accomplished this with:
var reportItem = report.TargetFolder + "/" + report.Name;
var dataSources = new DataSource[0];
dataSources = rs.GetItemDataSources(reportItem);
if (dataSources.Any())
{
var dataSource = (DataSourceDefinition)dataSources.First().Item;
dataSource.CredentialRetrieval = CredentialRetrievalEnum.Store;
dataSource.UserName = SsrsUsername;
dataSource.Password = SsrsPassword;
rs.SetItemDataSources(reportItem, dataSources);
}
I have build an Report application using C# and Crystal Report
I build program with Formula Selection to Change Query when User need to Filter the report.
The program build in Windows 7.
In the windows 7 program is running well as I needed, data and anything is shown like I needed.
But I need to run in Windows XP.
I try to filter date into to day.
The problem is on CrystalReportViewer RefreshReport();
If I don't use that function data on report doesn't refresh, but if I use that function The connection failed to logon
Here is the code:
skr = DateTime.Now.ToString("yyyy/MM/dd");
dp = new DailyParking();
dp.SetDatabaseLogon("user", "passwd", "host", "dbname");
repotviewer.ReportSource = dp;
repotviewer.SelectionFormula = "Date({transaksi1.masuk})=Date('" +skr+ "') ";
repotviewer.RefreshReport();
repotviewer.Refresh();
The answer is, Install the Another MySql Connector which compatible in XP, after that create the connection in MyODBC.
Change The code like here:
skr = DateTime.Now.ToString("yyyy/MM/dd");
dp = new DailyParking();
dp.SetDatabaseLogon("user", "passwd", "host", "dbname");
dp.RecordSelectionFormula = "Date({transaksi1.masuk}) = Date('" + skr + "') ";
repotviewer.ReportSource = dp;
repotviewer.Refresh();
Change the MySQL.Data reference with new MySQL connector same with installed in XP and Rebuil Program.
I'm trying to get a handle on the basics of report viewer control in a ASP.net Webforms project with C#. I'm using Adventure Work reports to get a feel for the basics.
I have a report called SalesOrderNumber under Report Parts on my SQL server
I just want to be able to view it at this point
if (!Page.IsPostBack)
{
// Set the processing mode for the ReportViewer to Remote
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
// Set the report server URL and report path
serverReport.ReportServerUrl =
new Uri("(!removed!");
serverReport.ReportPath =
"/Report Parts/SalesOrderNumber";
// Create the sales order number report parameter
ReportParameter salesOrderNumber = new ReportParameter();
salesOrderNumber.Name = "SalesOrderNumber";
salesOrderNumber.Values.Add("SO50750");
// Set the report parameters for the report
ReportViewer1.ServerReport.SetParameters(
new ReportParameter[] { salesOrderNumber });
I get back
The operation you are attempting on item '/Report Parts/SalesOrderNumber' is not allowed for this item type. (rsWrongItemType)
Assign full path like
"http://ReportServername/ReportFolderName/reportname.rdlc"
Make sure Report servername, ServerPath , ReportMode ,rendermode also
I know it's an old question but still I found - it needs an answer.
As per my view, we should first check report path that we have set.
The SSRS ReportPath setting must specify the full report path.
So if you want to access a report, you should set the below path,
http://YourServerName//ReportServer?/Foldername/ReportName
Note: if you've not created a folder on report server then no need to write FolderName. Directly write ReportName.
I would prefer to see below link if you want to access report server using URL.
Click here
Hope it would be helpful to others who are facing the same issue.
I am trying to open an access report through .net. I can open it in normal mode using Access.AcView.acViewNormal, but it's not what I want to do because that prompts the user to save the first and then it can be viewed. I want the report to pop up and it seems .acViewPreview or .acViewReport is what i should use, but it's not popping up.
It does open up a process and seems to be opening, but i can't see the report. Perhaps it's closing really fast. The following is the code I have currently
private void buttonResults_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Access.Application oAccess = new Microsoft.Office.Interop.Access.Application();
oAccess.OpenCurrentDatabase("D:\\path.mdb",true);
try
{
oAccess.DoCmd.OpenReport("rptChartData", Microsoft.Office.Interop.Access.AcView.acViewPreview);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
What am i doing wrong?? Thanks in advance...
I don't know Dot Net. I put this code in an Excel module and it created an Access instance and displayed my report. The key seemed to be oAccess.Visible = True Without setting Visible = True, Access opened (and remained open) with the report but was just not visible.
Dim strDbFullPath As String
Dim oAccess As Access.Application
strDbFullPath = "C:\Access\webforums\whiteboard2003.mdb"
Set oAccess = New Access.Application
oAccess.Visible = True
oAccess.OpenCurrentDatabase strDbFullPath, True
oAccess.DoCmd.OpenReport "rptFoo", acViewPreview
So I think this may not be a Dot Net issue, but standard behavior for an Access application instance.