cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report for hana with VS 2013

0 Kudos

Hi all,

I have a problem with a report made with crystal report.

The version of Crystal Reports Engine :

We have an add-on that use a report to print it. When we try to print the form ( UDO), we have this error :

"Database logon failed." at this line : reportDoc.PrintToPrinter(1, false, 0, 0);

There is the code we have use :

ReportDocument reportDoc = null;
try
{
	reportDoc = new ReportDocument();
}
catch (CrystalDecisions.CrystalReports.Engine.EngineException EE)
{
//Throw Exception
}
string sPath = null;
sPath = System.Windows.Forms.Application.StartupPath;
reportDoc.Load(sPath + "\\report.rpt");
TableLogOnInfo logOnInfo;

ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "xxx.xxx.xxx.xxx:30015";
crConnectionInfo.DatabaseName = "SBO_TEST";
crConnectionInfo.UserID = "SYSTEM";
crConnectionInfo.Password = "Password";

foreach (Table tbCurrent in reportDoc.Database.Tables)
{
	logOnInfo = tbCurrent.LogOnInfo;
	logOnInfo.ConnectionInfo = crConnectionInfo;
	tbCurrent.ApplyLogOnInfo(logOnInfo);
}
ParameterDiscreteValue param = new ParameterDiscreteValue();
ParameterValues paramValue = new ParameterValues();
param.Value = int.Parse(oEdit.Value.ToString());
paramValue = reportDoc.DataDefinition.ParameterFields[0].CurrentValues;
paramValue.Add(param);
reportDoc.DataDefinition.ParameterFields[0].ApplyCurrentValues(paramValue);
System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();

IntPtr Ihwnd = cIniFile.IniGetWindow(); //new WindowWrapper(Ihwnd)
System.Windows.Forms.DialogResult result = printDialog.ShowDialog(new WindowWrapper(Ihwnd));
if (result == System.Windows.Forms.DialogResult.OK)
{
	reportDoc.PrintOptions.PrinterName = printDialog.PrinterSettings.PrinterName;
	reportDoc.PrintToPrinter(1, false, 0, 0);
	SBO_Application.SetStatusBarMessage("Impression terminée !", SAPbouiCOM.BoMessageTime.bmt_Short, false);
}

How can we do to pass in this report the good credentials ? How can we resolve this error ?

Thanks for your help.

Best regards,

Michael

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

Your code looks ok to me, but I might be missing something. For a good example of how to set the credentials and the parameters, see don.williams blog post here: https://blogs.sap.com/2016/02/17/how-to-parameters-in-crystal-reports-for-visual-studio-net/

It contains examples for how to set the db credentials.

-Dell

Answers (0)