Hello everybody,
Greetings from Brazil! I need to pass parameters directly from TextBoxes in a windowsform to a Crystal Report IX through code, avoiding that ugly Crystal Report parameter prompt.
Can anybody please send me some sample code or let me know where I can find a tutorial I have searched the Internet for days but did not find anything.
Thanks a lot for your time and help! I really appreciate it.
All the best,
JC :)

C# 2005 - How do I pass parameters from TextBoxes in a windowsform to a Crystal Report IX ?
bhavu
bkallich
The code needed is:
myRepotDocument.SetParameterValue("MyParameterName", MyParameterValue);
longwood12345
donnie100
you need to create a reportdocument object first.
ReportDocument myReport = new ReportDocument();
myReport.Load(@"C:\MyReports\myReport.rpt");
Then set any parameters using the line I gave earlier.
Then view the report, or export, or whatever you want to do.
If you are creating the report as part of the object you can declare it using the filename without the extension. If you have a report called CrystalReport1.rpt then do the following:
CrystalReport1 myReport = new CrystalReport1();
This is equivalent to the two lines at the top
Khass
Hello mewdied,
It's all beginning to make sense to me now. I'm gonna set 3 parameters in the report itself and define the formulas for them:
prmClient
prmStartDate
prmEndDate
I will pass the parameters to the report from 3 textboxes in a windows form:
ClientTextBox
StartDateTextBox
EndDateTextBox
Are the following lines of code correct then
private void ShowReportButton_Click(object sender, EventArgs e)
{
ReportDocument myReport = new ReportDocument();
myReport.Load(@"C:\MyReports\myReport.rpt");
myRepotDocument.SetParameterValue("prmCliente", ClientTextBox.Text);
myRepotDocument.SetParameterValue("prmStartDate", StartDateTextBox.Text);
myRepotDocument.SetParameterValue("prmEndDate", EndDateTextBox.Text);
}
Thanks a lot for all your help! :)
B.Huard
SGriffiths