您好,
取得输入的参数要使用动态数据源绑定。通过args.Report.Parameters[0].Label记录参数。
- protected void WebViewer1_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
- {
- string productId = args.Report.Parameters[0].Label;
- string connStr = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("/Data/NWind_CHS.mdb"));
- string productSql = string.Format("SELECT * From 产品 where 产品ID = {0}", productId);
- DataLayer dl = new DataLayer(connStr, productSql);
- args.Data = dl.DataSetData.Tables["产品"];
- }
复制代码
- internal sealed class DataLayer
- {
- private DataSet dataSetData;
- public DataLayer(string connStr, string productSql)
- {
- LoadDataToDataSet(connStr, productSql);
- }
- public DataSet DataSetData
- {
- get { return dataSetData; }
- }
- private void LoadDataToDataSet(string connStr, string productSql)
- {
- dataSetData = new DataSet();
- OleDbConnection conn = new OleDbConnection(connStr);
- OleDbCommand cmd = new OleDbCommand(productSql, conn);
- OleDbDataAdapter adapter = new OleDbDataAdapter();
- adapter.SelectCommand = cmd;
- adapter.Fill(dataSetData, "产品");
- }
- }
复制代码 |