Failed to open the connection
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; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)