Print Page | Close Window

DataTable from input file and report

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Talk with the Author
Forum Discription: Ask Brian questions about his books and give him your comments. Like the book? Hate the book? Have suggestions? Let me know!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=8381
Printed Date: 04 May 2025 at 12:25am


Topic: DataTable from input file and report
Posted By: KennethS
Subject: DataTable from input file and report
Date Posted: 17 Nov 2009 at 10:57am
I have tried for about 3 hours this week to get a DataTable (from an input file) to work with Crystal Reports.  The code below are some of the things that I have tried. Confused

'' *** Add existing DataTable to new DS.
      Dim KeyWPrintTable As New DataTable
      Dim dsSelected1 As DataSet = New DataSet("KeyWPrintTable")

      Try

     
         '' *** Copy KeyWSelectedTable into the new DataTable.
         Dim myRows1 = From s In KeyWSelectedTable.AsEnumerable _
                      Where s.Field(Of Integer)(4) > 1 Or _
                      s.Field(Of Integer)(5) > 1 Select s

         KeyWPrintTable = myRows1.CopyToDataTable
         '' myReport1.SetDataSource(dsSelected1)
         '' CrystalReportViewer1.ReportSource = myReport1

         '' *** Try to get data from grid into report.
         DS_fromGrid1 = CType(DataGridViewSelected.DataSource, DataSet)
         myReport1.SetDataSource(DS_fromGrid1)
         CrystalReportViewer1.ReportSource = myReport1
         '' CrystalReportViewer1

The DataTable was created from the input file so I cannot drag anything over into the report. Ouch  I created the .rpt file and based it
on the schema file DataSet2.xsd.  What do I now need to do to get this report to fill with data and print? Confused 
myReport1.SetDataSource(DS_fromGrid1) gave an error. 

 Kenneth S.
 



-------------
Internet marketer, software and Web site developer.



Replies:
Posted By: jkwrpc
Date Posted: 19 Nov 2009 at 12:35pm

I am not certain how your dataset is constructed, nor whether dsSelected1 and DS_fromGrid1 are compatible. It  does seem that you either need to have two tables in the dataset or append the records of one to original table which I take to be KeyWSelectedTable.

I dont know if either of these thoughts will help.
 
Regards,
 
John W.
http://www.CustomReportWriters.net - www.CustomReportWriters.net


Posted By: KennethS
Date Posted: 19 Nov 2009 at 5:42pm
I only need some code to use either the Dataset or the
Datatable.  The .xsd file is set up and there is no database
to create the Datatable from it. I cannot find any Bind code for
the Crystal Report object to bind to the Datatable or Dataset.

 --- Kenneth
 


-------------
Internet marketer, software and Web site developer.



Print Page | Close Window