This example demonstrates how to bind a Microsoft SQL Server database file (.MDF) at runtime to a dashboard created in code.
To bind the dashboard to the Microsoft SQL Server database file, create a DashboardSqlDataSource instance and configure connection parameters.
NOTE: The MsSqlConnectionParameters object is not suitable for the SQL database file. You should use the CustomStringConnectionParameters instead.
The following connection string is used for .MDF file in this example:
XpoProvider=MSSqlServer;Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\NW19.mdf;Integrated Security=True
Database and log files NW19.mdf and NW19.ldf are not incuded in the project. They are copied to the working directory with the following post-build event command:
xcopy "$(ProjectDir)NW19*.*" $(TargetDir) /Y
The SelectQuery object is used to build a SQL query in code. You can also use the CustomSqlQuery to specify a SQL expression string.
NOTE: The SelectQueryFluentBuilder instance in not appropriate for this query because it does not support multiple JOINs.
The dashboard uses calculated fields. Create them in code and add to the DashboardSqlDataSource.CalculatedFields collection.
To bind dashboard items and calculated fields to the SQL Data Source, you should specify the Data Member setting. It is the name of the created SelectQuery.
- Dashboard for WinForms - How to Bind a Dashboard to an SQL Data Source
- Dashboard for WinForms - How to Replace the Dashboard Sql Data Source with the Dashboard Object Data Source
- Dashboard for WPF - How to bind a dashboard to a Microsoft SQL Server database file
(you will be redirected to DevExpress.com to submit your response)