locked
Publishing Lighswitch Application RRS feed

  • Question

  • I have Bing'd and Scroogled until my heyes have bled so I am here...

    I have a very small application I developed in LightSwitch and am ready to Publish it. Asusming SQL 2008 R2 Express isn't installed on the client PC or any of the prerequisites I have chosen to include the needed pre-reqs in the installer package. I also chose to create the SQL setup script. All this packages and publishes fine. When I launch the Setup.exe file, all needed prerequisites are installed fine as well.

    My only issue right now is that the databases and tables are not being created. In other words, the SQL setup script is not being run during the installation. My Silverlight application launches but there is the dreaded red 'X' in the Search Screen.

    How can I get the SQL script to run during setup? Is my connection string wrong?

    Data Source=.\SQLEXPRESS;Initial Catalog=myDataBase;Integrated Security=TRUE

    Many thanks for helping me learn...

    Wednesday, October 9, 2013 3:07 PM

Answers

  • When you used the LightSwitch publish wizard, did you configure it to publish directly to the database or did you configure it to generate a script file instead?  If you published it to a script file, you are responsible for executing that SQL script file yourself.

    Also, keep in mind that the intention is for each installation of your LightSwitch app on client machines to be sharing the same database located somewhere on the network.  LightSwitch doesn't explicitly provide support for the case where each client machine would have its own copy of the database.  So if you had used the connection string you provided above and had chosen to publish directly to the database, you would have been deploying the database to your local development machine.  And since the connection string is using the dot notation for the server rather than an explicit server name, the connection string is essentially relative based on which machine it is used on.  So when you install the app on a client machine, the app uses that connection string and expects the database to stored locally.  But you've done nothing to deploy the database locally on that client machine.  This would need to be a manual step if this is the sort of architecture you want.  But, as I said, LightSwitch is optimized for applications that all share a common database on a central machine.

    Thursday, October 10, 2013 8:23 PM

All replies

  • I had a similar issue once. You might want to check if the instance of SQLServer is "listening". You have to go into SQL Server configuration manager and set the start mode to Automatic for that service.

    Regards


    paul

    Thursday, October 10, 2013 7:05 AM
  • When you used the LightSwitch publish wizard, did you configure it to publish directly to the database or did you configure it to generate a script file instead?  If you published it to a script file, you are responsible for executing that SQL script file yourself.

    Also, keep in mind that the intention is for each installation of your LightSwitch app on client machines to be sharing the same database located somewhere on the network.  LightSwitch doesn't explicitly provide support for the case where each client machine would have its own copy of the database.  So if you had used the connection string you provided above and had chosen to publish directly to the database, you would have been deploying the database to your local development machine.  And since the connection string is using the dot notation for the server rather than an explicit server name, the connection string is essentially relative based on which machine it is used on.  So when you install the app on a client machine, the app uses that connection string and expects the database to stored locally.  But you've done nothing to deploy the database locally on that client machine.  This would need to be a manual step if this is the sort of architecture you want.  But, as I said, LightSwitch is optimized for applications that all share a common database on a central machine.

    Thursday, October 10, 2013 8:23 PM
  • Sorry for the delay, that thing called work gets in the way :)

    I realized the next day that the generated SQL script would need to be executed manually, so I just created a batch file that uses sqlcmd.exe the user executes after the pre-reqs and the application has installed. Works like a champ!

    Many thanks for your time everyone!@

    Saturday, October 12, 2013 3:42 AM