Crystal Report Database connection login failed - database-connection

I am using crystal report and trying to print an invoice. I am populating the crystal report through list of objects instead of database.But I am facing the crystal report database connection window. I need to bypass it.
My code is as below:
List<ReportHeader> RH = new List<ReportHeader>();
RH.Add(new ReportHeader("212EE212", "000004", "Asghar", "2234", "Ahmad", "Nice Transaction", "2/25/2016", "16:45"));
List<ReportDetail> RD = new List<ReportDetail>();
RD.Add(new ReportDetail("inpironD610", 3, 35000, 105000));
RD.Add(new ReportDetail("inpironD986", 3, 35000, 105000));
List<ReportFooter> RF = new List<ReportFooter>();
RF.Add(new ReportFooter(210000,4500,214500));
ReportDocument rptDoc = new ReportDocument();
InvoiceReport IR = new InvoiceReport();
IR.SetDataSource(RH);
IR.SetDataSource(RD);
IR.SetDataSource(RF);
IR.PrintToPrinter(1, true, 0, 0);
InvoiceReportViewer.ReportSource = IR;

Related

Microsoft ACE OLEDB connection creating filter like use "Excel.Application"

Can I make filter in created excel?
This is the standard connection string e.g. I create file Excel and save to disk
ConnectionString= "
|Provider=Microsoft.ACE.OLEDB.12.0;
|Data Source="+NameExcel+";
|Extended Properties=""Excel 12.0;HDR=Yes;IMEX=0;""";
Connection = new COMObject("ADODB.Connection");
Connection.Open(ConnectionString);
Command = new COMObject("ADODB.Command");
Command.ActiveConnection = Connection;
Command.CommandType = 1;
TablName= "Mane1";
Command.CommandText = "CREATE TABLE ["+NameTabl+"] ([Vagon] int, [Date op] date,
[Operation] char(255), [Date NSP] date)";
Command.Execute();
but I'd like to set filter on head My table
I have used "Excel.Application" I can do it used it:
Region = Excel.ActiveSheet.Range(Excel.ActiveSheet.Cells(1,1),Excel.ActiveSheet.Cells(1,CountColumn);
But I'm reaquared to use Microsoft.ACE.OLEDB.12.0 without "Excel.Application"

Ignite ML with multiple preprocessing

Using Ignite machine learning, say I have a labeled dataset like this:
IgniteCache<Integer, LabeledVector<Integer>> contents = ignite.createCache(cacheConfiguration);
contents.put(1, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 705.2, "HD", 29.97, 1, 1, 96.13 }), 2));
contents.put(2, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 871.3, "HD", 30, 1, 1, 95.35 }), 3));
contents.put(3, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 2890.2, "SD", 29.97, 1, 1, 95.65 }), 10));
contents.put(4, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 1032, "SD", 29.97, 1, 1, 96.8 }), 4));
How would I use the NormalizationTrainer on features 0 and 5 but the EncoderTrainer on feature 1? I think I'm having difficulties understanding how to concatenate multiple preprocessing before finally feeding the model trainer.
What I currently have is this (modified Ignite sample):
Vectorizer<Integer, LabeledVector<Integer>, Integer, Integer> vectorizer = new LabeledDummyVectorizer<Integer, Integer>(0, 5);
Preprocessor<Integer, LabeledVector<Integer>> preprocessor1 = new NormalizationTrainer<Integer, LabeledVector<Integer>>().withP(1).fit(ignite, data, vectorizer);
Preprocessor<Integer, LabeledVector<Integer>> preprocessor2 = new EncoderTrainer<Integer, LabeledVector<Integer>>().withEncoderType(EncoderType.STRING_ENCODER).withEncodedFeature(1).fit(ignite, data, preprocessor1);
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
KNNClassificationModel mdl = trainer.fit(ignite, data, preprocessor2);
Do I understand the multiple preprocessor correctly? If so, how would I add another BinarizationTrainer on feature 2? I think I'm getting confused by where to specify which feature to apply the preprocessing trainer on. For one trainer (NormalizationTrainer) I have to use the Vectorizer to tell which features to use, for the EncoderTrainer I can do this as a method function. How would I then add BinarizationTrainer with another Vectorizer?
One preprocessor builds on top of another.
Coordinates are relative to the preprocessor that comes before.
This example shows how to accomplish what you want to do:
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_6_KNN.java
put a breakpoint here: https://github.com/apache/ignite/blob/eabe50d90d5db2d363da36393cd957ff54a18d90/modules/ml/src/main/java/org/apache/ignite/ml/preprocessing/encoding/EncoderTrainer.java#L93
to see how the String Encoder references coordinates
examine all the variables:
UpstreamEntry<K, V> entity = upstream.next(); //this is the row from the file
LabeledVector<Double> row = basePreprocessor.apply(entity.getKey(), entity.getValue()); //after the previous preprocessor has been applied
categoryFrequencies = calculateFrequencies(row, categoryFrequencies); //use the given coordinates to calculate results.
more about preprocessing: https://apacheignite.readme.io/docs/preprocessing
Alternatively, you can use the pipelines API for a more streamlined approach to preprocessing: https://apacheignite.readme.io/docs/pipeline-api

Getting an error when creating the sample (empty) workbook with DocumentFormat.OpenXml (2.10.0)

I want to create a workbook with the data from my program, so I started with an empty one (code below). I tried with and without rows (the code has the rows code commented out), changing the order of a few lines but nothing works.
I took the code from Docs.Microsoft.com / here and http://www.dispatchertimer.com/tutorial/how-to-create-an-excel-file-in-net-using-openxml-part-1-basics/ (the samples are all about the same)
When I try to open the workbook in Excel I get an error: We found a problem with some content in 'Foo.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.
I used .NET Core (although I could also repro it with .NET Framework) and DocumentFormat.OpenXml Version: 2.10.0
What am I doing wrong?
Thanks
Jordi
using (SpreadsheetDocument document = SpreadsheetDocument.Create("D:\\Diff\\Sample2\\Foo.xlsx", SpreadsheetDocumentType.Workbook, false))
{
// A SpreadsheetDocument must have at least a WorkbookPart and a WorksheetPart
WorkbookPart workbookPart = document.AddWorkbookPart();
workbookPart.Workbook = new DocumentFormat.OpenXml.Spreadsheet.Workbook(); // Name ambiguity...
WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
Sheets sheets = workbookPart.Workbook.AppendChild(new Sheets());
Sheet sheet = new Sheet() { Id = workbookPart.GetIdOfPart(worksheetPart), SheetId = 1, Name = "Test" };
sheets.Append(sheet);
SheetData sheetData = worksheetPart.Worksheet.AppendChild(new SheetData());
////Row row = new Row();
////row.Append(
//// ConstructCell("Id", CellValues.String),
//// ConstructCell("Name", CellValues.String),
//// ConstructCell("Birth Date", CellValues.String),
//// ConstructCell("Salary", CellValues.String));
////// Insert the header row to the Sheet Data
////sheetData.AppendChild(row);
////uint id = 1;
////foreach (Spreadsheet spreadsheet in m_sheets.Values)
////{
//// Debug.Assert(spreadsheet != null);
//// spreadsheet.SaveToExcel(workbookPart, sheets, id++);
////}
workbookPart.Workbook.Save();
document.Close();
}
I did also post an issue in GitHub and I got a response there that pointed to this being a code error not a SDK error. Credit to Scott Haney since he replied to me on Github. The summary of the reply is:
It works for me if you remove the line (
SheetData
is already added to Worksheet when it was passed in as an argument to the constructor so this extra line causes it to be added twice):
SheetData sheetData = worksheetPart.Worksheet.AppendChild(new SheetData());
and also replace
workbookPart.Workbook.Save()
with
document.Save()
.

pass parameters to stored procedure from crystal reports designer

how to pass parameters to stored procedure from crystal reports designer
and in code also ??
If you use required stored procedure as source for report, while building report itself, you can pass stored procedure parameters from code as the following;
ReportDocument rptDocument = new ReportDocument();
// Load report.
rptDocument.Load(Server.MapPath("rptFileNameOrPath"));
ParameterFields parameterFields = new ParameterFields();
ParameterField parameterField = null;
ParameterDiscreteValue parameterValue = null;
parameterField = new ParameterField();
parameterValue = new ParameterDiscreteValue();
parameterField.Name = "#ContactId";
parameterValue.Value = "1";
parameterField.CurrentValues.Add(parameterValue);
parameterFields.Add(parameterField);
this.rptDocument.SetParameterValue("#ContactId", parameterValue);
#ContactId: is a parameter for required stored procedure.
Finally, you can either export report or print it based on your requirements.
// 0, 0: to print all the pages.
this.rptDocument.PrintToPrinter(1, false, 0, 0);
Regarding Crystal Report Designer, you just use View Report option, you will be asked to enter values for all report parameters, just enter required values.

Problem - Sending postscript data to printer using ExtEscape

I'm trying to send postscript data to the printer using ExtEscape, but the printer didn't respond at all for the following code (1st ExtEscape returned true. 2nd ExtEscape also returned true, but no print came out). I appreciate any help.
escapeCode = POSTSCRIPT_PASSTHROUGH;
if (bReturn = ExtEscape( printerDC, QUERYESCSUPPORT, sizeof(int),
(LPCSTR)&escapeCode, 0, NULL ) <= 0)
return;
bReturn = ExtEscape(
hdcPrint,
escapeCode,
sizeof(temp_out_ptr),
temp_out_ptr, // this contains postscript data
0,
NULL
);
Did you know using this method your data will be inserted into the middle of the drivers PostScript output.
If you want to spool a whole PostScript file directly to the printer bypassing the printer driver then you need something like this:
HANDLE ph = 0;
OpenPrinter(PrinterName, &ph, NULL);
DOC_INFO_1 di;
di.pDatatype = _T("RAW");
di.pDocName = DocumentName;
di.pOutputFile = NULL;
StartDocPrinter(ph, 1, (LPBYTE)(&di));
StartPagePrinter(ph);
DWORD dwWritten;
WritePrinter(ph, Data, LengthOfData, &dwWritten);
EndPagePrinter(ph);
EndDocPrinter(ph);
ClosePrinter(ph);

Resources