locked
Change SQL servers RRS feed

  • Question

  • Right in the middle of developing a new Lightswitch project (VS2012) the SQL server I was using for the data source failed. I was able to restore the database from backup to another SQL server on my network, but I can't find a way to tell Lightswitch that the data source has changed.

     The database on the new SQL server is the same database that Lightswitch has been using all along except for the fact that it is now on a different server. Can someone please point me in the right direction? How do I tell Lightswitch to connect to a different SQL server?

    Thanks

    Ed

    Wednesday, November 28, 2012 10:15 PM

Answers

  • If it's a published application, simply run the Publish Wizard again, & modify the connection string there.

    If you're still developing the application, & the database is an external data source, you can change the connection string information in the web.config file in either the ServerGenerated folder (LS 2011), or in the Server folder (LS 2012).


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Jyuma1 Thursday, November 29, 2012 11:37 AM
    Thursday, November 29, 2012 12:42 AM
    Moderator

All replies

  • If it's a published application, simply run the Publish Wizard again, & modify the connection string there.

    If you're still developing the application, & the database is an external data source, you can change the connection string information in the web.config file in either the ServerGenerated folder (LS 2011), or in the Server folder (LS 2012).


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Jyuma1 Thursday, November 29, 2012 11:37 AM
    Thursday, November 29, 2012 12:42 AM
    Moderator
  •  

    Thank you.

    I noticed in another post that you can right click on the database in the right
    navigation panel and then select update data source. I have used that many times
    to reload tables after I made changes in SQL.

    This time I noticed that the window that comes up for you to select the tables to reload
    has a "back button" at the bottom left and if you click it, a screen is displayed that apparently will allow you to select a different data source.

    Not knowing exactly what that would do I didn't dare click it, but is it possible that it
    is an easy way to change data source to a different server?


     



    • Edited by Jyuma1 Thursday, November 29, 2012 3:13 AM
    Thursday, November 29, 2012 3:12 AM
  • You know what? I think you *may* have stumbled onto something there! I hadn't even noticed that the Previous button was enabled.

    My only concern is that if you change the database that way, LightSwitch probably won't recognise that the schema of the database is the same as what was chosen before (even if it's exactly the same, like from a restored database), & might therefore remove all references to the old database & add the new ones. This would also have the effect of removing all associated controls on any screens. It's only a guess though, but it pays to assume that it would until you test it out, or someone from the LS team confirms that it definitely wouldn't.

    LightSwitch would be only doing this, thinking that it's what you intended, or because nobody thought that anyone could trigger ever this, if the button should have been disabled. But making the change in the web.config file would mean that LightSwitch wouldn't even be aware of the change, as it's only a connection string, which it has to look up anyway.

    So until you prove otherwise for yourself in a test project, or hear it from someone else who has tried it, the web.config file would remain the only safe method.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, November 29, 2012 3:36 AM
    Moderator
  • Agreed.  And thanks again for your help.
    Thursday, November 29, 2012 11:38 AM
  • You're welcome. :-)

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, November 29, 2012 11:52 AM
    Moderator