Hello friends I have a question, I have my report (.rpt) It shows good but when I press the button to see the folloging page It ask me for the parameter and the database authentication, this is my code:
cryRpt = new ReportDocument();
try
{
cryRpt.Load((Application.StartupPath + "\\rpExclu.rpt").Replace("\\bin\\Debug", ""));
cryRpt.SetParameterValue("@IDA", id);
cryRpt.SetDatabaseLogon("sa", "password$$$");
crvReportes.ReportSource = cryRpt;
crvReportes.Refresh();
}
catch (Exception ex)
{
crvReportes.Refresh();
XtraMessageBox.Show("" + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
cryRpt.Dispose();
cryRpt.Close();
}
Thanks in advance.
Morning friends. I modified my code in order to avoid asking parameters. I delete cryRpt.Dispose() and cryRpt.Close(). It works however I decided to put theses code lines in the winform closing event. My code is:
public FrmReport()
{
InitializeComponent();
rpDoc = new ReportDocument();
crvReportes.AllowedExportFormats = (int)(ViewerExportFormats.ExcelFormat | ViewerExportFormats.PdfFormat| ViewerExportFormats.WordFormat);
}
private void LoadReport()
{
try
{
rpDoc.Load((Application.StartupPath + "\\rpExclu.rpt").Replace("\\bin\\Debug", ""));
rpDoc.SetParameterValue("@IDA", this.ida);
rpDoc.SetDatabaseLogon(this.us, this.pass);
crvReportes.ReportSource = rpDoc;
crvReportes.Refresh();
}
catch (Exception ex)
{
crvReportes.Refresh();
XtraMessageBox.Show("" + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FrmReporteBienes_FormClosing(object sender, FormClosingEventArgs e)
{
if (rpDoc.IsLoaded)
{
rpDoc.Dispose();
rpDoc.Close();
}
}
Is it the best solution? Well in this moment It works. Thanks in advance.