This feature is intended to make it easy for you to connect to SQL Server from your app. It adds appropriate references and placeholders but still relies on you loading and displaying data within the app.
After adding this feature to your app you'll need to configure the connection appropriately. This is done in two places.
- In App.config specify the connection string that the app should use.
- In the SqlServerDataService class, optionally, add a fallback connection string to use if one is not specified in the config file.
If you change the name of the connection string from MyAppConnectionString
you must do so in the config file and in SqlServerDataService.GetConnectionString
.
Guidance on configuring accounts or connections for your database is beyond the scope of this document. If you're unsure of how to do this, talk to the DBA responsible for the database.
Apps generated by Template Studio use sample data in many pages. (These include ListDetails, Content Grid, DataGrid, and Chart.) If you're using any such page, you can easily change it to use data from a Northwind database instead. Firstly, specify a connection string to an instance of the Northwind sample database, then change SampleDataService
so that it uses SqlServerDataService.AllOrders()
instead of its own version of AllOrders()
. If connected correctly, you'll see more data shown in the page when you run the app. If there's an error making the connection, details will be written to the Debug
output window.
Once you've specified the connection details, you will need to load and display appropriate data for your app. Do this in the way you prefer or is appropriate to your needs. This service doesn't set a limit or place restrictions on how you do this. We do, however recommend using the GetConnectionString()
method as it encapsulates the logic for accessing the connection string from a hard-coded value, an app level config file, or a machine level config file.
After you've successfully connected to real data, we recommend deleting SqlServerDataService.AllOrders()
and the other sample data files as your app should no longer need them.