How to change my data source runtime RRS feed

  • Question

  • Hi All,

    Is there a way to change my data source runtime in LightSwitch HTML Application?

    Thanks in advance.

    Arun Kumar Asirvatham

    Thursday, February 28, 2013 8:17 AM

All replies

  • Hi Arun,

    Do you mean the connection string when you publish to a different machine? or are you talking a totally different type of source entirely?

    If its the first one, there's an option under Data Connections in the publish wizard that allows you to change the connection string on publish.



    Friday, March 1, 2013 12:38 AM
  • Thanks Pierson,

    My thought was not changing the data source while publishing, I want to make a LightSwitch HTML application to determine the site from where the app has invoked, and to take the current site's "Tasks" list as data source. Is this possible???

    In other words, I will create a LS HTML Application with data source as default "Tasks" list. After publishing it to different environment, the app has to determine, from where the app has invoked and to change the data source location dynamically. I think there should be a way to do so, since the connection string (here it is, SP WCF service URL) is in the web.config file o LS Solution.

    Hope this explains what I was trying to communicate. Please suggest.

    Arun Kumar Asirvatham

    Friday, March 1, 2013 2:22 PM
  • Hi Arun,

    Let me try and rephrase what you are telling me to make sure I have it right.

    You have an application that will take a SharePoint site's Task list. When you publish it, you want to use the new SharePoint site to get the Task list dynamically.

    Take a look at the following article and see if it helps you:

    Using Sharepoint Data in Your LightSwitch Applications

    It looks like what you want to do is update your Attached Data Source at publish time to use the new SharePoint service.

    In the publish wizard, on the Data Connections option, there's a tab called "Attached Data Sources" that allows you to update your SharePoint instance.

    Hope that helps.


    Friday, March 1, 2013 9:05 PM
  • Thanks Pierson,

    I understand your inputs. Is this the step that you are referring to?

    LightSwitch Publish Application Wizard

    In that case, I have another doubt to be clarified. Assume a situation, where I'm going to create a new SharePoint app PRODUCT, which means, any one can deploy my SharePoint app to their own site and it should work properly taking the "Tasks" list of root web. In such a situation, I'll not have an option to change the Connection URL. Right?

    Please correct me if I'm wrong.

    Arun Kumar Asirvatham

    Saturday, March 2, 2013 8:29 AM
  • Yes thats the Page i was referring to and yes the connection string would only be update at publish time. If you want your scenario to work, it will need to be custom code as it is not something that is supported in box. I don't know if you can find the connection string by querying anything within the app while running on the Sharepoint server. -Pierson
    Saturday, March 2, 2013 9:33 AM
  • Thanks a lot Pierson. 

    May be I need to put some code in the behind to change the connection string. I'll work on that. And very very thanks for your immediate response and ideas. Started loving 'LightSwitch'. :)

    Arun Kumar Asirvatham

    Saturday, March 2, 2013 9:56 AM
  • This has been asked many times before. LightSwitch does not do anything to help you implement multitenancy. You have to implement a data source (for example, a RIA Service) that understands how to dynamically connect to different data sources. Here's an little bit of an explanation in another thread: Dynamically switching datasource to a new database of exact same structure.

    Justin Anderson, LightSwitch Development Team

    Monday, March 4, 2013 9:49 AM
  • Thanks Justin,

    So the post you linked here shows only RIA services as data source, Is there any way to implement the same for data source from "SharePoint" or "REST services" ?

    Arun Kumar Asirvatham

    Thursday, March 7, 2013 5:35 AM