web应用程序传递连接字符串给FastReport数据源

时间:2023-03-09 02:00:40
web应用程序传递连接字符串给FastReport数据源

public static FastReport.Report fr = new FastReport.Report();

public static FastReport.EnvironmentSettings es = new EnvironmentSettings();

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

string path = Server.MapPath(@"\fr\Demo\1.frx");

if (System.IO.File.Exists(path) == true)

{

fr.Load(path);

es.DesignerSettings.ApplicationConnection = new System.Data.SqlClient.SqlConnection();                 es.DesignerSettings.ApplicationConnection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["DataConn"].ToString();                 //设置语言

FastReport.Utils.Res.LocaleFolder = Server.MapPath(@"\Localization");

FastReport.Utils.Res.LoadLocale(FastReport.Utils.Res.LocaleFolder + @"\Chinese (Simplified).frl");

fr.Design();

//fr.Show();             }         }