Connect SQL Server Database With LightSwitch

Introduction

In this article we are explaining how to connect to a SQL Server database in LightSwitch for Visual Studio 2012. A Visual Studio 2012 LightSwitch application allows you to connect to any type of data source.

The following data sources can be connected to in Visual Studio 2012 LightSwitch applications:

  1. SQL Server Databse.
  2. Share Point List.
  3. OData Service.
  4. WCF RIYA services.

How to connect a LightSwitch application to a SQL Server database

Step 1

Open Visual Studio 2012 and create a new "LightSwict application".

New-LightSwitch.png

Step 2

Go to Solution Explorer and right-click on "Data sources" and select "Add Data source".

Solution-Explorer-LightSwitch.png

Step 3

A new window will be shown. Select "Database" and click "Next".

Select-Datasource-LightSwitch.png

Step 4

In the Connection Properties dialog box, make sure that Microsoft SQL Server (SqlClient) appears as selected in the Data Source box and select your database name from the dropdown menu and click on "OK".

Connection-Properties-LightSwitch.png

Step 5

A new window will be shown. Select the table name that you want to add and click on "Finish".

Select-Table-LightSwitch.png

Step 6

After doing all that you will see the table structure in your application.

Table-Stru-LightSwitch.png

Step 7

Now run the application.


Similar Articles