Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Crystal Reports Viewer Subreport error Post Reply Post New Topic
Author Message
lewism
Newbie
Newbie


Joined: 06 Nov 2014
Location: United States
Online Status: Offline
Posts: 1
Quote lewism Replybullet Topic: Crystal Reports Viewer Subreport error
     Posted: 08 May 2015 at 3:23am
I am developing a crystal report using .net 4.0, crystal reports and VS 2010. I am programming visual basic. The basic concept of the report is a daily trucking report listing jobs, the trucks assigned to each job with a subreport detailing the cargo required for each job. The main report and the subreport are linked by a guid common between the stored procedure containing the job and trucking information and the materials table.   When I view the report on the crystal report page of the project, it appears exactly how I want it formatted. I see the jobs, the trucks assigned and the cargo to be delivered. However, when I attempt to run the report in Crystal Reports viewer the program throws an error. The subreport report throws the error “Column '' does not belong to table tblReqMaterial.” The code behind is shown below.
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Web
Imports CrystalDecisions.shared


Public Class _Default
    Inherits System.Web.UI.Page
    Public Shared tbl As DataTable

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        Dim dJobDate As Date = clsDBActions.dJobDate

        Dim myParameterField As New ParameterField
        Dim myParameterFields As New ParameterFields
        Dim myDescreetValue As New ParameterDiscreteValue

        Dim rpt As New crDispatchTrucks

        myParameterField.ParameterFieldName = "@JobDate"
        myParameterField.ParameterValueType = ParameterValueKind.DateParameter
        myDescreetValue.Value = dJobDate
        myParameterField.CurrentValues.Add(myDescreetValue)
        myParameterFields.Add(myParameterField)
        crTruckDispatches.ParameterFieldInfo = myParameterFields

        rpt.SetDataSource(GetData(dJobDate))

        rpt.Subreports("ReqMaterials").SetDataSource("tblReqMaterial")

       

        crTruckDispatches.ReportSource = rpt
        crTruckDispatches.RefreshReport()

    End Sub

    Private Function GetData(dJobDate As Date) As DataTable
        Using cnn As New SqlConnection(clsDBActions.RemoteJobcnn)
            cnn.Open()
            Using cmd As New SqlCommand
               cmd.CommandType = CommandType.StoredProcedure
               cmd.CommandText = "usp_TruckDispatchReportData"
               cmd.Connection = cnn
               cmd.Parameters.AddWithValue("@JobDate", dJobDate)
               Dim rdr As SqlDataReader = cmd.ExecuteReader
               If rdr.HasRows Then
                    tbl = New DataTable
                    tbl.Load(rdr)
               End If
            End Using
        End Using

        Return tbl
    End Function
End Class


The program errors out on the line.
rpt.Subreports("ReqMaterials").SetDataSource("tblReqMaterial")

The error is: System.ArgumentException: {"Column '' does not belong to table tblReqMaterial."}

I have spent several days trying to solve the problem to no avail. Any help would be greatly appreciated. Thank you for your assistance.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum