Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

Crystal Reports Viewer Subreport error

$
0
0

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.Data.SqlClient

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Web

Imports CrystalDecisions.shared

 

PublicClass_Default

      Inherits System.Web.UI.Page

      PublicShared tbl AsDataTable

 

    ProtectedSub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.Load

 

    Dim dJobDate AsDate = clsDBActions.dJobDate

   Dim myParameterField As NewParameterField

   Dim myParameterFields As NewParameterFields

   Dim myDescreetValue As NewParameterDiscreteValue

 

   Dim rpt AsNewcrDispatchTrucks

  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") <----- program errors out here

 


     crTruckDispatches.ReportSource = rpt


   crTruckDispatches.RefreshReport()

 

 

    EndSub

 

       PrivateFunction GetData(dJobDate AsDate) AsDataTable

 

        Using cnn AsNewSqlConnection(clsDBActions.RemoteJobcnn)

          cnn.Open()

            Using cmd AsNewSqlCommand
            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 = NewDataTable

               tbl.Load(rdr)

          EndIf

        EndUsing

       EndUsing

        Return tbl

    EndFunction

 

 

EndClass

 

The program errors out on the line.

 

 

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

 

I have spent several days trying to solve this puzzle.  Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>