0
我有一個應用程序與MsAcess數據庫。在它的一種形式中,我使用Crystal報表查看器來顯示一個水晶報表,但問題是在加載它的空白報告後,如果我嘗試刷新其給出錯誤刷新報告時登錄失敗
我的代碼報告如下
private void button1_Click(object sender, EventArgs e)
{
try
{
crystalReportViewer1.ReportSource = getpeport(@"C:\shrinkage\New folder\Shrinkage details1-bysreenath.rpt");
crystalReportViewer1.SelectionFormula = "{CONS_MAST.CONSID} = '" + cmb_cons.Text + "' and {CONSUMPTION.STYLE} = '" + cmb_style.Text + "' and {CONSUMPTION.BUYER} = '" + cmb_buyer.Text + "'";
//crystalReportViewer1.RefreshReport();
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString());
}
finally
{
oleDbConnection1.Close();
}
// crystalReportViewer1.RefreshReport();
}
public ReportDocument getpeport(String ReportLocation)
{
ConnectionInfo crconnectioninfo = new ConnectionInfo();
ReportDocument cryrpt = new ReportDocument();
TableLogOnInfos crtablelogoninfos = new TableLogOnInfos();
TableLogOnInfo crtablelogoninfo = new TableLogOnInfo();
Tables CrTables;
crconnectioninfo.ServerName = @"C:\shrinkage\Shrinkage.mdb";
crconnectioninfo.DatabaseName = "";
crconnectioninfo.UserID = "";
crconnectioninfo.Password = "";
cryrpt.Load(ReportLocation);
CrTables = cryrpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtablelogoninfo = CrTable.LogOnInfo;
crtablelogoninfo.ConnectionInfo = crconnectioninfo;
CrTable.ApplyLogOnInfo(crtablelogoninfo);
}
// cryrpt.Refresh();
return cryrpt;
}
本報告分別以水晶報告第十一設計,有我能夠做到的刷新和查看數據also.Pls幫我建議