on 01-29-2015 5:50 PM
Hello,
i get the following error while exporting a report. This report contains a single numeric parameter "TabID".
What i make wrong ?
Thank you in advance.
[Environment]
Windows 7 x64
Visual Studio 2013 Community Edition
Crystal Reports v13.0.2000.0 for Visual Studio
[Exception]
CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException was unhandled
HResult=-2147215870
Message=Fehlende Parameterwerte.
Source=CrystalDecisions.ReportAppServer.DataSetConversion
PromptEngineAvailable=false
StackTrace:
bei CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
bei CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
bei CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
bei CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
bei CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatType formatType, String fileName)
bei TestCrystalReport.Form1..ctor() in c:\projects\TestCrystalReport\TestCrystalReport\Form1.cs:Zeile 29.
bei TestCrystalReport.Program.Main() in c:\projects\TestCrystalReport\TestCrystalReport\Program.cs:Zeile 19.
bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Runtime.InteropServices.COMException
HResult=-2147217394
Message=missing parameter values.
Source=Analysis Server
ErrorCode=-2147217394
StackTrace:
bei CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
bei CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
InnerException:
[SourceCode]
CrystalDecisions.CrystalReports.Engine.ReportDocument ReportDocument=new CrystalDecisions.CrystalReports.Engine.ReportDocument();
string ReportDocumentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string ReportDocumentExportFilePath=ReportDocumentFilePath + "\\CrystalReport1.pdf";
ReportDocumentFilePath+= "\\CrystalReport1.rpt";
ReportDocument.Load(ReportDocumentFilePath);
ReportDocument.SetParameterValue("TabId",7);
ReportDocument.SetDatabaseLogon("user","password");
ReportDocument.Refresh();
ReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, ReportDocumentExportFilePath);
Hi Mathias
Set the parameter after you logon to the database.
If you are changing your datasource, use .ApplyInfo rather than SetDatabaseLogon.
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ludek ,
Thanks for the quick reply. I have changed the source code as proposed. Unfortunately without success -> the same error message .
Could you check my sourcecode please ?
- Mathias
[SourceCode]
CrystalDecisions.CrystalReports.Engine.ReportDocument ReportDocument=new CrystalDecisions.CrystalReports.Engine.ReportDocument();
string ReportDocumentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string ReportDocumentExportFilePath=ReportDocumentFilePath + "\\CrystalReport1.pdf";
ReportDocumentFilePath+= "\\CrystalReport1.rpt";
ReportDocument.Load(ReportDocumentFilePath);
//ReportDocument.SetDatabaseLogon("sa","sa1234");
foreach (CrystalDecisions.CrystalReports.Engine.Table ReportTable in ReportDocument.Database.Tables)
{
ReportTable.LogOnInfo.ConnectionInfo.UserID="user";
ReportTable.LogOnInfo.ConnectionInfo.Password="password";
ReportTable.ApplyLogOnInfo(ReportTable.LogOnInfo);
}
ReportDocument.SetParameterValue("TabId", 7);
ReportDocument.Refresh();
ReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, ReportDocumentExportFilePath);
You need to add the database info to the connection collection:
ReportTable.LogOnInfo.ConnectionInfo.Server="IP or Server PC Name"; // or DSN name if connecting via ODBC
ReportTable.LogOnInfo.ConnectionInfo.Database="YourDBDatabase";
You can get this info from the RPT file using:
// get the DB name from the report
CrystalDecisions.Shared.NameValuePair2 nvp2 = (NameValuePair2)rpt.Database.Tables[0].LogOnInfo.ConnectionInfo.Attributes.Collection[1];
And I believe the Parameter name may need @ in front of:
ReportDocument.SetParameterValue("@TabId", 7);
Try wrapping all CR functions in a Try/Catch block so you can get more details about the error.
try
{
.... your code
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Don
Hi Ludek,
Thanks for the help. I could solve the problem with it.
Thanks for your time.
- Mathias
[SourceCode]
CrystalDecisions.CrystalReports.Engine.ReportDocument ReportDocument=new CrystalDecisions.CrystalReports.Engine.ReportDocument(); |
string ReportDocumentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); | |
string ReportDocumentExportFilePath=ReportDocumentFilePath + "\\CrystalReport1.pdf"; | |
ReportDocumentFilePath+= "\\CrystalReport1.rpt"; | |
ReportDocument.Load(ReportDocumentFilePath); |
try | |
{ |
CrystalDecisions.Shared.ConnectionInfo connectionInfo = new CrystalDecisions.Shared.ConnectionInfo(); |
connectionInfo.UserID = "sa"; | |
connectionInfo.Password = "sa1234"; | |
connectionInfo.ServerName = ".\\SQLEXPRESS"; | |
connectionInfo.DatabaseName = "mydb"; |
foreach (CrystalDecisions.CrystalReports.Engine.Table table in ReportDocument.Database.Tables) | ||
{ | ||
table.LogOnInfo.ConnectionInfo = connectionInfo; | ||
table.ApplyLogOnInfo(table.LogOnInfo); | ||
} |
ReportDocument.SetParameterValue("TabId", 15); |
crystalReportViewer1.ReportSource = ReportDocument; |
} | |
catch (Exception ex) | |
{ |
MessageBox.Show(ex.ToString()); | ||
} |
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.