Existing Data – LightSwitch has shown us this week how easy it is to create a fully data aware application in a very short amount of time and with minimal developer effort. But what about adding existing data?
I received a message from a reader in Johannesburg this week. His company used an Access database for one of their applications, but needed to migrate away from Access (probably because the data grew large enough to warrant the use of SQL). They had already created the SQL database and migrated the data, and now needed to quickly create a user interface.
His question to me was what technology he could use to create a GUI in the shortest amount of time, without having to learn how to program. Obviously I suggested LightSwitch.
Add Your Existing Data
You might wonder how to add your existing database to a LightSwitch application? This week we have seen that data is what drives LightSwitch. Adding an existing data source is really easier than you think.
From the Visual Studio Solution Explorer, right click on data sources and select ‘Add Data Source…’ from the context menu.
For the purposes of this post, I’ll just be using an existing SQL Database, but you can connect to different sources should you wish.
On the next screen we will select Microsoft SQL Server.
Specify your connection details to your server and select the existing database you wish to use. (You probably know where this is going right?)
The next screen allows you to select tables and views.
Seeing as I only want Sales Order data from my existing database, I expand the Tables node and select the appropriate tables for Sales Order Header and Detail data.
Clicking on Finish will add your data source under the Data Sources folder in Solution Explorer and add the table diagrams to your designer (complete with relationship if it finds one).
The next step is to add a screen to represent your data. From here on out, it is old hat. Exactly as in the previous articles, you configure your screens as you prefer.
I have master / detail data to represent, so the best screen for me would be to add the List and Details Screen. Select the data source table (I added the Master table) and check the master and details as additional data to include.
Your designer now lists the data bound controls for your screen.
Click on run and see LightSwitch work it’s magic with your existing data source. Under the sales orders column on the left of my application, I can see all the sales order numbers. Clicking on a sales order number populates the data on the sales order data fields to the right. At the very bottom, the sales order details are displayed in the data grid.
Adding existing data to your LightSwitch application is just as easy (if not easier) as creating a new LightSwitch application with a new data source.I hope that you enjoy exploring LightSwitch as much as I do. If you missed my previous articles on LightSwitch, you can read them at the following links:
Until next time, happy exploring!
Latest posts by Dirk Strauss (see all)
- The Daily Six Pack: October 8, 2014 - 8 October, 2014 06:00:42
- The Daily Six Pack: October 7, 2014 - 7 October, 2014 06:00:33
- The Daily Six Pack: October 6, 2014 - 6 October, 2014 06:00:29
- Setting Different Wallpapers For Each Monitor In Windows 8 – Thanks Scott - 6 October, 2014 01:00:51
- The Daily Six Pack: October 2, 2014 - 2 October, 2014 06:00:08