private void BindToData(XtraReport report) { //// Create a data source. //Access97ConnectionParameters connectionParameters = new Access97ConnectionParameters("../../nwind.mdb", "", ""); String connStr = "TestProject.Properties.Settings.NorthwindConnectionString"; DevExpress.DataAccess.Sql.SqlDataSource ds = new DevExpress.DataAccess.Sql.SqlDataSource(connStr); // Create an SQL query to access the master table. CustomSqlQuery queryCategories = new CustomSqlQuery(); queryCategories.Name = "queryCategories"; queryCategories.Sql = "SELECT * FROM Categories"; // Create an SQL query to access the detail table. CustomSqlQuery queryProducts = new CustomSqlQuery(); queryProducts.Name = "queryProducts"; queryProducts.Sql = "SELECT * FROM Products"; // Add the queries to the data source collection. ds.Queries.AddRange(new SqlQuery[] { queryCategories, queryProducts }); // Create a master-detail relation between the queries. ds.Relations.Add("queryCategories", "queryProducts", "CategoryID", "CategoryID"); // Assign the data source to the report. report.DataSource = ds; report.DataMember = "queryCategories"; }
void BindToData() { // Create a SQL data source with the specified connection string. SqlDataSource ds = new SqlDataSource("NWindConnectionString"); // Create a SQL query to access the Products data table. SelectQuery query = SelectQueryFluentBuilder.AddTable("Products").SelectAllColumnsFromTable().Build("Products"); ds.Queries.Add(query); ds.RebuildResultSchema(); // Add the created data source to the list of default data sources. ASPxReportDesigner1.DataSources.Add("Northwind", ds); ASPxReportDesigner1.OpenReport("Report"); }
protected void ASPxDashboard1_DataLoading(object sender, DataLoadingWebEventArgs e) { if (e.DataId.StartsWith("ods|")) { string[] names = e.DataId.Split("|".ToCharArray()); List <DashboardSqlDataSource> dataSources = (List <DashboardSqlDataSource>)Session["ds" + e.DashboardId]; DashboardSqlDataSource dataSource = dataSources.First(ds => ds.ComponentName == names[1]); SqlQuery query = dataSource.Queries.First(q => q.Name == names[2]); XElement dsXML = dataSource.SaveToXml(); DevExpress.DataAccess.Sql.SqlDataSource sqlDS = new DevExpress.DataAccess.Sql.SqlDataSource(); sqlDS.LoadFromXml(dsXML); sqlDS.ConnectionName = dataSource.ConnectionName; sqlDS.Fill(query.Name); ResultSet rSet = ((IListSource)sqlDS).GetList() as ResultSet; ResultTable rTable = rSet.Tables.First(t => t.TableName == query.Name); if (query.Name == "Invoices") { var dt = ConvertResultTableToDataTable(rTable); for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (((DateTime)dt.Rows[i]["OrderDate"]).Year < 2016) { dt.Rows.RemoveAt(i); } } e.Data = dt; } else { e.Data = rTable; } } }