locked
sqlexpress won't connect in iis RRS feed

  • Question

  • User-1260064810 posted

    When running from VisualStudio, the page display correctly, but viewing from iis, it gives error because connecting to sqlexpress failed.  What causes that and how to fix it?

    Thanks.

    Friday, February 26, 2016 6:58 PM

Answers

  • User-1260064810 posted

    Thanks to all who replied. 

    It turned out I need to install sql express first. One of the answer says, in IIS a different user is used to access sqlexpress database.  That is right.  But without sqlexpress engine, nothing would work.  After installation, configure the Application Pool to use NerworkService account to access the database.  Everything is working now.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 4, 2016 5:32 PM

All replies

  • User2050872319 posted

    Hi comego,

    IIS runs your app under different user account.

    There's an article on how to configure it: http://www.iis.net/learn/manage/configuring-security/application-pool-identities-and-sql-server-express

    Friday, February 26, 2016 7:33 PM
  • User364663285 posted

    Try to put this

    	<connectionStrings>
    		<add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
    	</connectionStrings>
    



    within Web.config/app.config file in your project, to ensure the project will work fine with the database.

    Tuesday, March 1, 2016 4:39 AM
  • User-1260064810 posted

    Thanks to all who replied. 

    It turned out I need to install sql express first. One of the answer says, in IIS a different user is used to access sqlexpress database.  That is right.  But without sqlexpress engine, nothing would work.  After installation, configure the Application Pool to use NerworkService account to access the database.  Everything is working now.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 4, 2016 5:32 PM