Torna al Thread

private void frmReport_Load(object sender, EventArgs e) { myReport = new ReportDocument(); string path = "report\\Caso.rpt"; try { myReport.Load(path); myReport.SetParameterValue("@id", _id); // imposta la connessione al db SetDBLogonForReport(); // imposta il viewer crrvMain.ShowLogo = false; // visualizza il report crrvMain.ReportSource = myReport; crrvMain.Zoom(1); } catch (Exception ex) { MessageBox.Show("Attenzione: " + ex.ToString(), "", MessageBoxButtons.OK); } } // imposta i dati di connessione per il report // nome server, nome db sono memorizzati all'interno del report private void SetDBLogonForReport() { ConnectionInfo conn = new ConnectionInfo(); conn.Type = ConnectionInfoType.SQL; conn.ServerName = "dbServer"; conn.DatabaseName = "dbName"; conn.UserID = "x"; conn.Password = "x_password"; TableLogOnInfo LInfo = new TableLogOnInfo(); foreach (CrystalDecisions.CrystalReports.Engine.Table table in myReport.Database.Tables) { LInfo = table.LogOnInfo; LInfo.ConnectionInfo = conn; table.ApplyLogOnInfo(LInfo); } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5