Visual Studio Development Bookmark and Share   
 index > Crystal Reports for Visual Studio > Printing using a dataset
 

Printing using a dataset

My application allows the user to enter Invoice Info into an SQL database.

When the user starts the app. the dataset Invoice_DS is loaded with all pertinent info about current Invoices.

at any given time there are about 200 - 300 invoices in this dataset. The dataset is also made up of 7 tables.

Header, Details, and supporting tables.

When the user is finished entering the data she needs to print a copy of the invoice.

I have tried to print using the Invoice_DS dataset just to see if I am getting some data out. I realize there are a few hundred records there and I eventually only want to print the Invoice that the user is currently viewing.

I tried using the following code to print using a Dataset. But I only get a blank layout of the Invoice Printout.

Code Snippet

Dim crReportDocument As InvPRT2

crReportDocument = New InvPRT2()

crReportDocument.SetDataSource(Invoice_DS)

''Set the viewer to the report object to be previewed.

CrystalReportViewer1.ReportSource = crReportDocument

CrystalReportViewer1.PrintReport()

I don't want to have the report Query the db each time because that seems like a huge waste of resources. I already have the data in hand. Can anyone tell me of the correct approach to this ?

Thanks

tattoo

tattoo  Thursday, August 02, 2007 11:06 PM

Did you add a data set(typed dataset) to your project.The structure of this dataset should be same as your untyped dataset, the one you created in code (Invoice_DS). Design your report using that typed dataset.

For this go to Field Explorer > Database fields > Add/Remove database > find XML source as data specify path to your typed dataset file.All the tables you created in

The name of both typed and untyped dataset should be same as well the structure.

NOw debug your application , just before you setData source check that there is data in dataset (Invoice_DS)

Regarding your second question for efficient use of resource.

create another table in your dataset with only those columns that you need in your report, now fill this newtable with data from rest of your tables, only fill that data that the userhas selected.This way you will always fetch data from dataset not Database.

captJackSparrow  Friday, August 03, 2007 8:20 AM

Did you add a data set(typed dataset) to your project.The structure of this dataset should be same as your untyped dataset, the one you created in code (Invoice_DS). Design your report using that typed dataset.

For this go to Field Explorer > Database fields > Add/Remove database > find XML source as data specify path to your typed dataset file.All the tables you created in

The name of both typed and untyped dataset should be same as well the structure.

NOw debug your application , just before you setData source check that there is data in dataset (Invoice_DS)

Regarding your second question for efficient use of resource.

create another table in your dataset with only those columns that you need in your report, now fill this newtable with data from rest of your tables, only fill that data that the userhas selected.This way you will always fetch data from dataset not Database.

captJackSparrow  Friday, August 03, 2007 8:20 AM

Thanks Cappy, that worked like a charm..

tattoo

tattoo  Monday, August 06, 2007 9:47 PM

You can use google to search for other answers

Custom Search

More Threads

• Crystal Reports--selecting fields at run time
• Crystal Report not working
• question about crystal report
• .Net and Cognos report
• Refreshing a crystal report in asp.net
• Need To Send records in DataGridView to a Dataset/DataTable and append it to crystal Report
• VS 2005 compatibility with CR 11.5 r2
• Using Custom Paper
• Integrated Security
• the type initialize for 'crystalDescisions.crystalreports.engine.reportdocument' threw an exception