PDA

View Full Version : ارسال پارامتر به كريستال ريپورت



afshindelphikar
پنج شنبه 14 شهریور 1387, 10:36 صبح
سلام
ميخواستم بدونم چه جوري ميشه به كريستال ريپورت پارامتر ارسال كرد مثلا با انتخاب نام يك شخص از درون يك كامبو باكس ركورهاي اون شخصو در كريستال نمايش داد ممنون ميشم كمك كنيد:بوس:

Moslemu
پنج شنبه 14 شهریور 1387, 10:53 صبح
سلام.


//
//Create the select command
//
_CommandText = "SELECT * FROM tableName " + strWhereStatement;

//
//Set the objects that needed
//
DataSet objDataSet = new DataSet();
OleDbDataAdapter objDataAdapter = new OleDbDataAdapter(_CommandText, objConnection);
reportName rptResults = new reportName();

if (objConnection.State != ConnectionState.Open)
objConnection.Open();
try
{
objDataAdapter.Fill(objDataSet, "tableName");
}
catch
{
string strError = "خطا در تهيه‌ي گزارش... ";
MessageBox.Show(strError, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
}

rptResults.SetDataSource(objDataSet);

rptResults.SetParameterValue("PagesTitle", txt1.Text);
rptResults.SetParameterValue("ReportDate", txt2.Text);

FrmReports FrmRpt = new FrmReports();
FrmRpt.crystalReportViewer1.ReportSource = rptResults;
FrmRpt.crystalReportViewer1.Refresh();
FrmRpt.ShowDialog();