简体   繁体   中英

Cannot connect to SQL Server Express 2014 from Visual Studio 2012

My question is regarding retrieving data from SQL Server (Express 2014) into Visual Studio (Professional 2012). I am following a tutorial re usage of the drop down list. When I use 'Choose Data Source' I can proceed as far as selecting the database. When I try to use 'Microsoft SQL Server Database File (SqlClient)' and select 'NORTHWND.MDF' from my App_Data folder I get this error:

The attempt to attach to the database failed with the following information: A network-related or instance-specific error occurred while establishing an connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections (provider: SQL Network Interfaces, error:50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)

I have nothing in the log re this.

When I try and connect to SQL Server using 'Microsoft SQL Server' I can get to the SQL Server Instance, select the database and get 'Connection Successful' but on OK get this error:

Could not load file or assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version 11.0.0.0 Culture=neutral, Public Key Token=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

I have installed SQLLocalDB.

Help greatly appreciated as this is holding up my studies. Thank you.

I finally found a message in the application event log which pointed out an incompatibility issue... I presumed this was between VS 2012 and SQL Server 2014. Accordingly I installed SQL Server 2012. Subsequently running a 'Web Application' in VS 2012 I found that the 'Register' function in the automatically created page correctly created a user whereas previously it had failed with the error originally posted. I am assuming that all SQL Server related activities in VS 2012 will now work, but will report back here if I find otherwise.

Follow the below steps

  1. Open sql server management studio 2014
  2. Right click on your database and select properties
  3. Select permissions and select View Server Permissions link
  4. Select the user name pc-name or current user name
  5. Give permissions to connect and create databases
  1. Download and install, LocalDB 64BIT\\SqlLocalDB.msi, from http://www.microsoft.com/en-in/download/details.aspx?id=42299 .
  2. Open an administrator command prompt and run - sqllocaldb create “v12.0″
  3. Under Visual Studio menu items -> click on Tools -> Options -> Under the Database Tools node, choose Data Connections. Change SQL Server instance name to (LocalDB)\\v12.0

Refer - For SqlLocalDB Utility – http://msdn.microsoft.com/en-us/library/hh212961.aspx For local database overview – http://msdn.microsoft.com/en-us/library/ms233817.aspx

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