المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : c# vs2008 Reportviewer is not closing the database [modified]



C# Programming
08-11-2009, 11:12 PM
Hi all,

I have an issue with the report viewer. I created my reports with reportviewer tool and everything
works ok.
My problem is, once I created a report and close the report form and then I tried to update
something on my database I always received and error message that the database cannot been opened.
So my question here is ... How can I force reportviewer to close any database opened after I close
my report form?

Here is the complete code of my report form:


using System;
using System.Windows.Forms;

namespace SACK
{
public partial class frmReportes : Form
{
public frmReportes()
{
InitializeComponent();
}

private void frmReportes_Load(object sender, EventArgs e)
{
this.repViewer.*******Report();
}

private void btnSalir_Click(object sender, EventArgs e)
{
this.Close();
}

private void btbGenerarReporte_Click(object sender, EventArgs e)
{
DateTime fechaIni = Convert.ToDateTime(dtpFechaIni.Text);
DateTime fechaFin = Convert.ToDateTime(dtpFechaFinal.Text);

// Reporte de Entradas
if (rbuEntradas.Checked)
{
try
{
this.tPrinterTableAdapter.FillByEntradas(this.KardexPrinterDBDataSet.tProductos, fechaIni, fechaFin);
this.repViewer.LocalReport.ReportEmbeddedResource = "SACK.ReportByEntradas.rdlc";
this.repViewer.*******Report();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
// Reporte de Salidas
if (rbuSalidas.Checked)
{
try
{
this.tPrinterTableAdapter.FillBySalidas(this.KardexPrinterDBDataSet.tProductos, fechaIni, fechaFin);
this.repViewer.*******Report();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
// Reporte de Entradas / Salidas
if (rbuSalidas.Checked)
{
try
{
this.tPrinterTableAdapter.FillByEntradasSalidas(this.KardexPrinterDBDataSet.tProductos, fechaIni, fechaFin);
this.repViewer.*******Report();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
// Reporte de Existencias
if (rbuSalidas.Checked)
{
try
{
this.tPrinterTableAdapter.FillByExistencias(this.KardexPrinterDBDataSet.tProductos, fechaIni, fechaFin);
this.repViewer.*******Report();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}
}
}


Hope someone can help me on this... thank you!:cool

modified on Tuesday, August 11, 2009 2:56 PM