简体   繁体   中英

SQL Network Interfaces, error: 50 after moving to new PC

I am at a loss as to how to fix this issue.

When running my MVC application and trying to access the user database I get the dreaded SQL Network Interfaces, error: 50.

I can see all the data in the Server Explorer in VS, but I can never get the application to see it.

I have spent sometime reading this;

SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance 9

I have renamed and created new databases. I have added/changed the entry in the applicationHost.config file. I have changed the connection string every which way from Sunday. I just cant figure it out. Here is my connection string in the Webconfig file.

 <add name="UserConnection" connectionString="Data Source=(LocalDB)\V11.0;AttachDbFilename=|DataDirectory|\ShopUsers.mdf;Initial Catalog=ShopUsers;Integrated Security=True" providerName="System.Data.SqlClient" />

I even downloaded and ran the ContosoUniversity sample code to see if it works, and it does. Here is that connection string, (that works fine)

<add name="SchoolContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>

It seems there is something amiss between IIS and the db Server.

Any new ideas would be greatly appreciated.

Oh ya, I did have this working just fine on my old PC.

Seems like you have the database file created already (I suspect you do because of the following segment: AttachDbFilename=|DataDirectory|\\ShopUsers.mdf; ). If so, then ensure you have it in the same folder beneath your project as the original one on your old PC, usually the |DataDirectory| stands for App_Data (look the answer to this question ).

If, you need a brand new database however, you should have tried the following connection string:

<add name="UserConnection" connectionString="Data Source=(localdb)\v11.0\ShopUsers;Initial Catalog=ShopUsers;Integrated Security=True" providerName="System.Data.SqlClient" />

This will create the database for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM