Current filter:
                                You should refresh the page.

                                  • Hi I am trying to add a datasource to a Dashboard Designer programmatically so that the query results show in the field navigator window on the left.  This is what I have tried, and it seems to show the datasource in the dropdown, but nothing appears in the field navigator window.   Can you please help me?  Thanks.


                                           Dim oConnect As SqlConnectionStringBuilder = New SqlConnectionStringBuilder(_Globals.GetConnectionString())
                                            Dim dataSource As String = oConnect.DataSource
                                            Dim dataBase As String = oConnect.InitialCatalog
                                            Dim ocParamaters As New DevExpress.DataAccess.ConnectionParameters.MsSqlConnectionParameters(dataSource, dataBase,         oConnect.UserInstance, oConnect.Password, DevExpress.DataAccess.ConnectionParameters.MsSqlAuthorizationType.Windows)
                                            Dim ocConnection As New DevExpress.DataAccess.DataConnection("localhost_GembaWorksConnection", ocParamaters)
                                            Dim CompanyDataProvider As New DevExpress.DashboardCommon.SqlDataProvider(ocConnection, "SELECT * FROM BLAH...")
                                            Dim CompanyData As New DevExpress.DashboardCommon.DataSource(CompanyDataProvider)
                                            Me.DashboardDesigner1.Dashboard.DataSources.Add(CompanyData)
                                            DashboardDesigner1.SelectedDataSource = DashboardDesigner1.Dashboard.DataSources(0)


                                1 Solution

                                Creation Date Importance Sort by
                                You can use following code to add data source at runtime. 
                                [C#]
                                Dashboard dashboard = new Dashboard(); var northwindDataSource = new DevExpress.DashboardCommon.DashboardSqlDataSource("Northwind", new MsSqlConnectionParameters() { AuthorizationType = MsSqlAuthorizationType.Windows, ServerName = "localhost", DatabaseName = "Northwind" }); var invoicesQuery = new TableQuery ("Invoices"); var invoicesTableInfo = invoicesQuery.AddTable("Invoices"); invoicesTableInfo.SelectColumns( new string[] {"ProductName", "OrderDate", "ExtendedPrice" }); northwindDataSource.Queries.Add(invoicesQuery ); //Note that if you add a data source to a dashboard that is already shown in the DashboardDesigner, //it is necessary to call the DataSource.Fill Method to populate data.  //If you configure the dashboard first and assign it after that, this method will be called automatically.  //northwindDataSource.Fill(); dashboard.DataSources.Add(northwindDataSource); var gridItem = new GridDashboardItem() { DataSource = northwindDataSource, DataMember = "Invoices" }; gridItem.Columns.Add(new GridDimensionColumn(new Dimension("ProductName"))); gridItem.Columns.Add(new GridMeasureColumn(new Measure("ExtendedPrice"))); dashboard.Items.Add(gridItem); dashboardDesigner1.Dashboard = dashboard;

                                [VB.NET]
                                Dim dashboard As New Dashboard() Dim northwindDataSource = New DevExpress.DashboardCommon.DashboardSqlDataSource("Northwind", New MsSqlConnectionParameters() With { .AuthorizationType = MsSqlAuthorizationType.Windows, .ServerName = "localhost", .DatabaseName = "Northwind" }) Dim invoicesQuery = New TableQuery("Invoices") Dim invoicesTableInfo = invoicesQuery.AddTable("Invoices") invoicesTableInfo.SelectColumns(New String() {"ProductName", "OrderDate", "ExtendedPrice"}) northwindDataSource.Queries.Add(invoicesQuery) 'Note that if you add a data source to a dashboard that is already shown in the DashboardDesigner, 'it is necessary to call the DataSource.Fill Method to populate data.  'If you configure the dashboard first and assign it after that, this method will be called automatically.  'northwindDataSource.Fill() dashboard.DataSources.Add(northwindDataSource) Dim gridItem = New GridDashboardItem() With { .DataSource = northwindDataSource, .DataMember = "Invoices" } gridItem.Columns.Add(New GridDimensionColumn(New Dimension("ProductName"))) gridItem.Columns.Add(New GridMeasureColumn(New Measure("ExtendedPrice"))) dashboard.Items.Add(gridItem) dashboardDesigner1.Dashboard = dashboard

                                Note that if you add a data source to a dashboard that is already shown in the DashboardDesigner, it is necessary to call the SqlDataSource.Fill Method to populate data. If you configure the dashboard first and assign it after that, this method will be called automatically. 



                                • Michael Berry 06.28.2015

                                  Thank you.  This works.  For anyone reading this I made one simple adjustment to make my sql query work instead of the fixed table fills:

                                  I commented out:
                                  'Dim invoicesTableInfo = invoicesQuery.AddTable("Results")
                                  'invoicesTableInfo.SelectColumns(New String() {"ProductName", "OrderDate", "ExtendedPrice"})

                                  and added:

                                  Dim invoicesQuery = New DevExpress.DataAccess.Sql.CustomSqlQuery("MyQueryName", "SELECT * FROM Table1,Table2, etc ...")
                                  northwindDataSource.Queries.Add(invoicesQuery)
                                  northindDataSource.Fill()
                                  dashboard.DataSources.Add(northwindDataSource)

                                • Constant (DevExpress Support) 06.29.2015
                                  I am happy to hear that my assistance was helpful for you. Thank you for informing me and for sharing your solution with us.