locked
asp.net mvc 4 local database to sql database after publish RRS feed

  • Question

  • I have built a mvc 4 intranet application that uses a local db to store info. Now that i want to deploy it on a server entries are not saving to the database. I have tried everything i can think of with no luck.

    Is there a way to tell the application to use a sql database instead of a local instance in iis?

    This is the connection string in my web.config

    -- edit: formatted code below so it would show up in the question. --

    <add name="MyCalendarConnectionString" connectionString="Data Source=DST09119\SQLEXPRESS;Initial Catalog=MyCalendar;Integrated Security=True"
          providerName="System.Data.SqlClient" />
        <add name="SampleConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Sample.mdf;Integrated Security=True"
          providerName="System.Data.SqlClient" />
    • Moved by Caillen Monday, November 11, 2013 4:25 AM ASP.NET question.
    Friday, November 8, 2013 10:06 AM

Answers

  • Hi,

    I would like to recommend that you post your question in ASP.NET forum where you could receive better responses.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Friday, May 2, 2014 7:57 PM
    • Marked as answer by Just Karl Monday, May 12, 2014 8:16 PM
    Monday, November 11, 2013 4:24 AM

All replies

  • <copied>

    Is there a way to tell the application to use a sql database instead of a local instance in iis?

    <end>

    IIS has nothing to do with this.

    <http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/preparing-databases>

    I don't know what your purpose of using a mdf (deployed local instance) file in an ASP.NET solution is about. But take note on this. Using  a local instance means that only one user at a time can have the file open, and another user is  going to be blocked from using the local instance of the mdf file until the current user closes the file. This is not a good situation  in a mutil user ASP.NET application that is using a database.

    The mdf file needs to be attached back to the SQL Server Engine running on a single machine that is hosting SQL Server Express on the network and point the connection string to the machine and the database if it is to be used in a multi user ASP.NET solution. 

    If you are thinking about using the mdf file on a server machine using a server O/S like Win 2k8 with using the server version of SQL Server, then you should be using the SQL Server Express scripting tools on that mdf file that you attached back to a local running version of SQL Server Express and script out the mdf database file with the scripting tools.  

    You then take the scripts and you run the scripts on the machine running the server version of SQL Server to build the database and tables on the server version of SQL Server.

    Friday, November 8, 2013 2:27 PM
  • Hi,

    I would like to recommend that you post your question in ASP.NET forum where you could receive better responses.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Friday, May 2, 2014 7:57 PM
    • Marked as answer by Just Karl Monday, May 12, 2014 8:16 PM
    Monday, November 11, 2013 4:24 AM
  • Hello,

    Specifically, this should be asked in the ASP.Net MVC forum on forums.asp.net.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    Friday, May 2, 2014 7:57 PM