PDA

Click to See Complete Forum and Search --> : [RESOLVED] [2005] Write to Crystal Report


WaZda
Jan 15th, 2008, 03:14 AM
Hi everybody and i wish u all a happy new year.
Am working on a project whereby i have to send some informations to a crystal report. Am using Visual Studio 2005. I would like to do some query to the SQL server then do some manipulations with the data and then send some of the data manipulated to report. I can do the query and the manipulation alright but i don't how to send the informations to the text box placed on my report.
Can someone please help?
Thank you.

Hack
Jan 15th, 2008, 07:09 AM
Moved to Reporting

MANNO
Jan 16th, 2008, 05:48 AM
you can create a parameter in the report then make the textbox in the report equal to the parameter value then sent the parameter value by code

WaZda
Jan 17th, 2008, 02:45 AM
Hi, MANNO
That is exactly what am trying to do but i dont know how to do the codings, am very new to Crystal report. Pls help.
WaZda

MANNO
Jan 17th, 2008, 04:35 AM
ok here is the code:

the Imports:
Imports Microsoft.Reporting.WinForms

and here is the code in the Button:
Dim sDate As New ReportParameter("Report_Parameter_1", CType(DateTimePicker1.Value.ToShortDateString, Date))
Dim eDate As New ReportParameter("Report_Parameter_2", CType(DateTimePicker1.Value.ToShortDateString, Date))
Dim TName As New ReportParameter("Report_Parameter_3", CType(TextBox1.Text, String))

ReportViewer1.LocalReport.SetParameters(New ReportParameter() {sDate, eDate, TName})
ReportViewer1.RefreshReport()

I hope it helps
Good Luck

Note:
This is a visual basic code

WaZda
Jan 21st, 2008, 04:03 AM
Hi MANNO,
Am having an error with the "ReportParameter" saying the type is not defined. Can u help me on dat?
Plus the scenario is dat:
form1: I will do the data manipulation in the form1 then finally send the information to the form2.
form2: i have a report viewer to load the report file. Informations should be received from form1 by codes onto the report.

WaZda
Jan 21st, 2008, 04:16 AM
Hi MANNO,
Thank you very much for your help. i tried to understand your code but i just couldn't. and it is because i did make myself clear enough. So i'll try explaining better this time, here is the scenario:
I have 3 files: Form1, Form2 and CrytalReport1.rpt(which is the crystal report file)
form1: I will do the data manipulation in the form1 then finally send the information to the form2.
form2: i have a CrystalReportViewer to load the CrystalReport file (CrytalReport1.rpt). Informations should be received from form1 by codes and displayed in the various textbox, placed on the CrytalReport1.rpt .

I hope this one is much clearer. and once again, thank you for helping me.
WaZda

kleinma
Jan 23rd, 2008, 09:05 AM
Here is a working demo. This should explain everything you need to know, and you SHOULD have no problem applying this to your own project.

WaZda
Jan 23rd, 2008, 09:52 AM
Oh my GOD,
kleinma dude, u solved my problem. This is great man. your project Rocks. Am so grateful to you buddy. Really.

kleinma
Jan 23rd, 2008, 09:56 AM
sometimes a demo is worth a 1000 posts trying to explain something ;)

WaZda
Jan 23rd, 2008, 01:00 PM
sure man, you a RIIIIIIIIIIIght. thank u. u saved me on this one.
Take care.
WaZda

WaZda
Jan 24th, 2008, 06:17 AM
Kleinma,
One more question pls. I have some other print out that should follow the first one. And what am trying to do is,
1.if possible, get to know the printer the user selected then use that printer for the other printings.
2. Freeze the app with some progress bar to wait till the end of all the printings before going back to it.
Thank you for your help. Coz u r really helping me and i appreciate that.

WaZda