Trouble linking subReport to Main Report

Originally Posted 3 October 2016, 4:50 pm EST

  • Originally Posted 3 October 2016, 4:50 pm EST

    c1Rpt.DataSource.RecordSource = "MasterSet";
    c1Rpt.DataSource.Filter = "";
    c1Rpt.DataSource.ConnectionString = "";
    c1Rpt.DataSource.Recordset = MasterSet.Tables["Student"];
    if (subReports != null && subReports.Count > 0)
    {
    string HoldFilter;
    foreach (string subRpt in subReports.Keys)
    {
    if (subReports[subRpt] == null)
    { subReports.Add(subRpt, subReports[subRpt]); }
    HoldFilter = subReports[subRpt].DataSource.Filter;
    DataTable sourceTable = MasterSet.Tables["Course"];
    subReports[subRpt].DataSource.RecordSource = "MasterSet";
    subReports[subRpt].DataSource.Filter = "";
    subReports[subRpt].DataSource.ConnectionString = "";
    subReports[subRpt].DataSource.Recordset = sourceTable;
    SetOptions(DocDefID, subReports[subRpt]);
    }
    }
    MasterSet is a DataSet that contains 3 DataTables - Student, Course and School. The DataTables are built from a schema and are in memory ready for reporting. There is no database for this application as everything is handled in xml.

    subReport.Text = Course.Course_ID = Student.Student_ID
    subReport.DataSource.Filter = User_Field_10 = '1'

    When I attempt to rendertoFile(strFileName, FileFormatEnum.PDF) I get the following error from MSVS - Cannot find column [Course.Course_ID].

  • Reply

    It appears that I can't upload my report definition... The xml file was blocked by your server.
  • Reply

    Hi,
    I think, there is some problem in columns name. can you try to check them again?
    Because, I could not replicate the issue at my end.

    Please find a sample application attached for implementing the same.

    If this does not solve your issue. Please send us a small sample application or modify the attached one so that we can assist you accordingly.

    Note: Please attached anything as Zip file.

    Thanks,
    Sonu
    2016/10/SetRecordSetForSubReport.zip
  • Reply

    Setting the connectionstring property to null had no effect on the outcome of reults.
  • Reply

    Correction.... the relationship is Course.Student_ID = Student.Student_ID.

    Sorry for the mixup. I did verify all columns and, when I observe the c1Rpt object, I do find the following layout associated with the subreport:

    In the DataSourceInfo property I find Student_ID as the 2nd field DataType is string. Is the subreport position sensitive in the fields list? Is it required that Student_ID be the first column in the Course structure?
  • Reply

    I don't know if a stack dump will help or not???? I'm trying to get you all the information needed to resolve this issue!

    System.Data.EvaluateException was unhandled
    HResult=-2146232032
    Message=Cannot find column [Course.Student_ID].
    Source=C1.C1Report.4
    StackTrace:
    at C1.C1Report.C1Report.#VUd(Exception exception, Boolean fatal)
    at C1.C1Report.C1Report.#VUd(Exception exception, Boolean fatal)
    at C1.C1Report.DataSource.#URd(Boolean quiet)
    at C1.C1Report.C1Report.RenderFirstPass(Boolean releaseDocument)
    at C1.C1Report.C1Report.#2Ud()
    at C1.C1Report.C1Report.#0Ud()
    at C1.C1Report.Field.#oTd(Double x, Double y, Boolean measure)
    at C1.C1Report.Field.Render(Layout layout, Double x, Double y, Boolean measure)
    at C1.C1Report.Field.Render(Layout layout, Double x, Double y)
    at C1.C1Report.Section.Render(Boolean keepPage, Group ownerGroup)
    at C1.C1Report.Section.Render()
    at C1.C1Report.Group.Render()
    at C1.C1Report.C1Report.#AJc()
    at C1.C1Report.C1Report.RenderFirstPass(Boolean releaseDocument)
    at C1.C1Report.C1Report.#2Ud()
    at C1.C1Report.C1Report.#0Ud(ExportFilter filter, Boolean reuse)
    at C1.C1Report.C1Report.RenderToFile(String fileName, FileFormatEnum fmt)
    at WebEDGE_Student.Controllers.ReportRender.RenderToFile(String strFileName) in C:\Projects\WebEdge Student\WebEDGE Student\Controllers\ReportController.cs:line 188
    at WebEDGE_Student.Controllers.PDF.SendPDF2Location(SaveFileDialog SFD) in C:\Projects\WebEdge Student\WebEDGE Student\Controllers\Output.cs:line 156
    at WebEDGE_Student.Controllers.DynamicToolStripMenuItem.send2Output(String selection, String ArchiveRootPath, String formDocID, String DocDefID, ToolStripProgressBar tsprgStatus) in C:\Projects\WebEdge Student\WebEDGE Student\Controllers\AppController.cs:line 146
    at WebEDGE_Student.Controllers.UIController.send2Output(DynamicToolStripMenuItem menuItem, String DocDefDescription, ToolStripProgressBar tsprgStatus) in C:\Projects\WebEdge Student\WebEDGE Student\Controllers\AppController.cs:line 772
    at WebEDGE_Student.WorkflowMonitor.tsDDBPresentation_Click(Object sender, EventArgs e) in C:\Projects\WebEdge Student\WebEDGE Student\Workflow.cs:line 296
    at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
    at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
    at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
    at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
    at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
    at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.ToolStrip.WndProc(Message& m)
    at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at WebEDGE_Student.Controllers.AppController.Main() in C:\Projects\WebEdge Student\WebEDGE Student\Controllers\AppController.cs:line 65
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException:
  • Reply

    You're using a MS Access Database and I am not. There is a relation foreign key set in the DataSet in memory for the purposes of reporting. ComponentOne was implemented by the previous programmer very poorly and I am attempting to remove all that overhead! I stripped the report definition down to 1 subreport for the purposes of resolving this issue. I intentionally did not add any fields to the subreport as to not inject anything into resolving this relational issue. Attached you will find my subreport.

    2016/10/elmont_portrait_ERC.zip
  • Reply

    I did notice a subtle difference with you coding in that you set the connectionstring property to null and I had set the property to "". I have changed that and am testing the changes to see if that makes a difference.
  • Reply

    The relationship is Course.Course_ID = Student.Course_ID. I verified these columns. These columns are important for the foreignkey constraint in the DataSet.
  • Reply

    Hi,
    Can you please share your tables structure? Which is used in your attached report.
    So that we can replicate the same issue at my end and provide a solution for the same.

    Also please check the behavior with the latest build of WinForms which can be downloaded from the link below:
    http://prerelease.componentone.com/dotnet20/c1winforms/2016-t2/C1WinForms.2_2.0.20162.188.zip
    http://prerelease.componentone.com/dotnet40/c1wpfreport/2016-t2/C1WPFReport_4.0.20162.188.zip

    Thanks,
    Sonu
  • Marked as Answer

    Reply

    Thanks for your input, Sonu... It was after all the link to the main report. I am programmatically setting that property. Where I had Course.Student_ID = Student.Student_ID, I changed the property to reflect the following in c#....
    "\"[Student_ID] = '\" & [Student_ID] & \"'\""

    So, you were right in your initial assessment. The problem was the difference in VB and escaping in c#.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels