Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have been searching all over different sources in search on solving my issue.. I've published a website on IIS that I have been working on and this is my first published website on IIS.

I seem to not be able to connect to the database.

I will provide everything that I have done right down here..

Appreciate any help please....

My web.config file in the published website directory C:FinancialHubTest. On a side note I also tried adding User Instance=True to my connection string in my web.config file but it doesn't work..

<connectionStrings>
    <!--<add name="ConnStr" connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFileName=|DataDirectory|FinancialHub.mdf;Integrated Security=True" />-->
    <add name="ConnStr" 
         connectionString="Data Source=(LocalDB).IIS_DB;Integrated Security=True;" />
</connectionStrings>

Details of MSSQLLocalDB from cmd

MSSQLLocalDB

applicationHost file in C:WindowsSystem32inetsrvconfig edited with Notepad2. I'm using FinancialHub as my applicationPool for my published website in IIS

<applicationPools>
        <add name="DefaultAppPool" managedRuntimeVersion="v4.0" />
        <add name="Classic .NET AppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
        <add name=".NET v2.0 Classic" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
        <add name=".NET v2.0" managedRuntimeVersion="v2.0" />
        <add name=".NET v4.5 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" />
        <add name=".NET v4.5" managedRuntimeVersion="v4.0" />
        <add name="FinancialHub" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
          <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
        </add>
        <applicationPoolDefaults managedRuntimeVersion="v4.0">
            <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="false" />
        </applicationPoolDefaults>
    </applicationPools>

My Published Website directory with App_Data having the FinancialHub.mdf file

mdf

My SQL Server Object Explorer, the connection only appears when I run my website via Visual Studio 2015 I think that would be running on IIS Express..

sql

I have been getting this error every time I change here and there but I'm really sure why.. Or rather what changes I make to either web.config, etc will cause this error. I check the windows event log too.

errorsql

I also followed these 2 links on dealing with this issue,

Using LocalDB with Full IIS, Part 1: User Profile,

Using LocalDB with Full IIS, Part 2: Instance Ownership

If there is a need for more information i can provide..

I feel like i have been beating around the bush trying to figure out but i can't seem to solve it..

I really do appreciate any help please. Thank you so much.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
143 views
Welcome To Ask or Share your Answers For Others

1 Answer

You are still using LocalDB even after publishing the application to IIS. LocalDB (SQL Database inside App_Data) is primarily intended for developing and testing purpose only.

You need a real SQL Server when you host the site on IIS. So you need to install SQL Server either in the same server that the application is hosted or a dedicated SQL server. Then attach or copy the existing database to SQL Server.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...