I use devexpress xtrareports v.15 for winforms in my project.
I have invoice report. It has some text fields inside and one list. I connect data to sources in report ctor:
public InvoiceReport(InvoiceCommonData icd, List<ReportPosition> positions)
{
InitializeComponent();
this.ReportCommonDataSource.DataSource = icd;
this.positionsList.DataSource = positions;
}
When I print report as it was created in Visual Studio data is connected in right way.
But I need to load different layouts for this report. I store report layout as repx file and try to load it from file at runtime:
InvoiceReport report = new InvoiceReport(model.GetCommonData(), model.GetPositions());
var filename = "D://InvoiceReport.repx";
report.LoadLayout(filename);
When I print report I see that common data (icd) was bound and is printed but list (positions) was not bound and it is empty table instead of real data.
Question is how to load xtrareport layout from file and save all data connections?
but i think u can try to replace connection of default repx file to your main connection becouse when we create repx file from report designer that time we set connection and repx save as default when we try to preview report with viewer file get default save connection so try to replace connection from required sql connection .
like if (((DevExpress.DataAccess.Sql.SqlDataSource)devxReport.DataSource).ConnectionParameters != null) //change if connection exists in report
{
((DevExpress.DataAccess.Sql.SqlDataSource)devxReport.DataSource).ConnectionParameters = null;
}
((DevExpress.DataAccess.Sql.SqlDataSource)devxReport.DataSource).ConnectionParameters =
new DevExpress.DataAccess.ConnectionParameters.CustomStringConnectionParameters(sqlConnectionString);
Related
I am trying to build an Android Xamarin Application. I have created an SQLite database named regjistri.sqlite . The database it's not corrupted, I can open it via SQLite browser on my PC. This database I have save it to my android Documents folder.
I am trying to access it like below via sqlite-net-pcl library.
string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "regjistri.sqlite");
var db = new SQLiteConnection(dbPath);
var data = db.Query<object>("SELECT COUNT(*) FROM tblLidhja ");
Also I have gice the application the reading and writing permissions. When I debug it via USB cable, it give me the "SQLite.SQLiteException: no such table: tblLidhja" exception. Can someone help me whats may be wrong, or what should I change to read some data?
Before getting data , first need to check whether this table is exist in data base .You can refer to this document to check .
By the way ,having a try with this way to get count from database:
var db = new SQLiteConnection("DbPath");
var stocksStartingWithA = db.Query<TableName>("SELECT * FROM DbNmae ");
int count = stocksStartingWithA.Count; //get count from table
Here is similar discussion with java code, but it also can be refer in xamrin project.
Short Version :
If an error is thrown during the execution of an SSRS report after the associated RDP temporary tables have been updated, the next time the report is run for the same parameters, code execution does not insert fresh data into said tables. Any idea why and how to prevent it?
Long Version :
I am trying to modify the run conditions of a standard report (SalesInvoiceReport) so that the original of any invoice can only be printed once. For all reprints, the "Copy preview" option should be used.
For the most part, the customization is working as intended. I used the CustInvoiceJour.PrintedOriginals field and the CustInvoiceJour.updatePrintedOriginals() (both part of Standard Ax) to maintain the number of originals that have been printed and a slight modification to the SalesInvoiceController.outputReport() method throw an error of an original is being re-printed. Below is the code added to achieve this :
...
// <A147> Code to disable reprints if an original is already printed
isOriginalPrintable = CustInvoiceJour::findRecId(custInvoiceJour.RecId).PrintedOriginals == 0;
srsPrintDestinationSettings = formLetterReport.getCurrentPrintSetting().parmPrintJobSettings();
//srsPrintMediumType = srsPrintDestinationSettings.printMediumType();
if ((printCopyOriginal == PrintCopyOriginal::Original || printCopyOriginal == PrintCopyOriginal::OriginalPrint))
{
// If no originals printed, allow prints.
// Need to re-read the CustInvoiceJour record from the table to get updated data
// If the Original is printed but the prin form is not refreshed, the form's recordset does not update to the latest data.
if(isOriginalPrintable)
{
CustInvoiceJour::updatePrinted(custInvoiceJour, (srsPrintDestinationSettings.numberOfCopies() == 0 ? 1 : srsPrintDestinationSettings.numberOfCopies()));
}
// Don't allow the original document to be printed more than once.
else
{
error(strFmt("#GLS223085", custInvoiceJour.InvoiceId, custInvoiceJour.InvoiceDate));
return;
}
}
// </A147>
...
I placed this in the SalesInvoiceContreller.outputReport() because I found similar code present there as part of standard Ax, albeit for use in specific country regions.
When user uses the Original Preview button, the error is thrown and code execution stops but the RDP temporary tables used to hold the report data have already been updated with report data (specifically the field which hold the Report title is set to Invoice).
When the user reruns the report, this time with the Copy Preview button, code execution somehow skips inserting fresh data into the temp tables (which would set the Report Title field to Invoice Copy) and the first copy output still says Invoice, defeating the requirement.
I am creating reporting server using asp.net mvc web api. I am retrieving data from web api retriving report using XRDesignForm object of devexpress. I am posting back report data to web api. what issue i am facing is, and if i use xtrareport obejct and bind datasource manually it work fine.i.e.
XtraReport report = new XtraReport();
report.DataSource = setupSummary.FillDataSet();
report.DataMember = ((DataSet)report.DataSource).Tables[0].TableName;
designForm.OpenReport(report);
//designForm.Show();
designForm.ShowDialog(this);
I can successfully mainuplate this report and can save into database,
But as shown in articles for ReportStorage, if i only retrieve report from database using report name from server, datasource is always null.i.e.
XRDesignForm designForm = new XRDesignForm();
string url = GetSelectedUrl();
if (!string.IsNullOrEmpty(url))
designForm.OpenReport(url);
designForm.ShowDialog(this);
It seems that when saving dynamic report into database (as binary), It loss data source bindings.
please help me for this.
thanks
Aqdas, thank you very much.
There is a similar error in the report layout,
My solution is, after the layout again set DataSource
XtraReport rep = null;
rep = new rptReqVac();
Stream layoutStream = null;
layoutStream = mGetLoyoutStream(id);
rep.LoadLayout(layoutStream);
rep.DataSource = new dsREQPrintVac();
reportDesigner.OpenReport(rep);
Hope it will help someone :-)
Finally after spending lot of time, i had fixed this, Issue is actually when you save report to database as binary, it skip DataAdapter for report. so before saving you need to do first null to dataadapter or report and then assaing again before you get buffer for report layout.
Hope it will help someone :-)
I want to Export a table from my database to an excel file on the server and then download it. The following is the code that I developed for this purpose:
import flash.net.FileReference;
import flash.net.URLRequest;
public function sqlDownloadExcel():void {
var http:HTTPService = new HTTPService;
var parm:Object = new Object;
var sql:String;
sql = "insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\\inetpub\wwwroot\\myApp\\App_Data\\myExport.xls;', 'SELECT * FROM [Sheet1$]') SELECT * FROM myTable";
parm.sql = sql;
parm.db = "myDatabase";
http.url = "http://mywebsite.com/SQLconnector/sqlconnector.asp?irand="+Math.random();
http.showBusyCursor = true;
http.request = sql;
http.addEventListener(ResultEvent.RESULT, function(e:ResultEvent):void {sqlDownloadExcelResult(e);});
http.addEventListener(FaultEvent.FAULT, mssqlFault);
http.method = "POST";
sqlToken = http.send(parm);
}
public function sqlDownloadExcelResult(event:ResultEvent):void{
var request:URLRequest = new URLRequest("http://mywebsite/myApp/App_Data/myExport.xls");
var fileRef:FileReference = new FileReference();
fileRef.download(request);
}
The code creates the Excel file on the server correctly, but running the fileRef.download(request) functions causes the following error:
Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
Any advice would be much appreciated.
Thank you
You can't do what you want. Security restrictions prevent your app from trying to download anything to the clieht machine without user input. That is why you're seeing the error.
I recommend creating the excel sheet on the server, saving it to the server, and then sending a URL back to your Flex app. Use navigateToURL() to open it; and the browser should handle it based on the client's browsers settings. It may download automatically; or open automatically; or it may prompt the user what it wants to do.
If necessary, you can create a server side script to routinely clean out the generated files.
Based on the code you provided, it looks like you are 90% of the way there. Just instead of using FileReference to try to download the file, use navigateToURL() to open that URLRequest.
Alternatively, you could modify your UI to say "You're file is ready, click here to get it" or something similar. Then you have user interaction and can open the download window after the user clicks the button.
I have integrated the below code in my application to generate a 'pdf' file using crystal reports in MVC project.
However, after the request is processed, i get to see only 2 pages in the pdf file while my 'data' returns more than 2 records.
Also, the pdf isn't rendered as soon as the page is processed but instead i have to refresh atleast once, then the pdf is rendered on the browser.
using CrystalDecisions.CrystalReports.Engine;
public FileStreamResult Report()
{
ReportClass rptH = new ReportClass();
List<sampledataset> data = objdb.getdataset();
rptH.FileName = Server.MapPath("[reportName].rpt");
rptH.Load();
rptH.SetDatabaseLogon("un", "pwd", "server", "db");
rptH.SetDataSource(data);
Stream stream = rptH.ExportToStream
(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, System.IO.SeekOrigin.Begin);
return new FileStreamResult(stream, "application/pdf");
}
I took the code from here in SO but modified it like above.
TIA.
EDIT: This works on Firefox, not in IE7.
I finally found the solution here on SO. It had nothing to do with MVC but the way IE treats popup window.