Error 50 произошла ошибка local database runtime

To begin — there are 4 issues that could be causing the common LocalDb SqlExpress Sql Server connectivity errors SQL Network Interfaces, error: 50 - Local Database Runtime error occurred, before you begin you need to rename the v11 or v12 to (localdb)mssqllocaldb

Possible Issues
  • You don’t have the services running
  • You don’t have the firelwall ports here
    configured
  • Your install has and issue/corrupt (the steps below help give you a nice clean start)
  • You did not rename the V11 or 12 to mssqllocaldb
 \ rename the conn string from v12.0 to MSSQLLocalDB -like so-> 
 `<connectionStrings>
      <add name="ProductsContext" connectionString="Data Source= (localdb)mssqllocaldb; 
      ...`

I found that the simplest is to do the below — I have attached the pics and steps for help.

First verify which instance you have installed, you can do this by checking the registry& by running cmd

 1. `cmd> Sqllocaldb.exe i` 
 2. `cmd> Sqllocaldb.exe s "whicheverVersionYouWantFromListBefore"` 
if this step fails, you can delete with option `d` cmd> Sqllocaldb.exe d "someDb"
 3. `cmd> Sqllocaldb.exe c "createSomeNewDbIfyouWantDb"` 
 4. `cmd> Sqllocaldb.exe start "createSomeNewDbIfyouWantDb"`

SqlLOCALDb_edited.png


ADVANCED Trouble Shooting Registry configurations

Edit 1, from requests & comments: Here are the Registry path for all versions, in a generic format to track down the registry

Paths

// SQL SERVER RECENT VERSIONS
HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server(instance-name)

// OLD SQL SERVER
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesMSSQLServer
HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSSQLServer
// SQL SERVER 6.0 and above.

HKEY_LOCAL_MACHINESystemCurrentControlSetServicesMSDTC
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesSQLExecutive
// SQL SERVER 7.0 and above

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesSQLServerAgent
HKEY_LOCAL_MACHINESoftwareMicrosoftMicrosoft SQL Server 7
HKEY_LOCAL_MACHINESoftwareMicrosoftMSSQLServ65

Searching

SELECT registry_key, value_name, value_data  
FROM sys.dm_server_registry  
WHERE registry_key LIKE N'%SQLAgent%';

or Run this in SSMS Sql Management Studio, it will give a full list of all installs you have on the server

DECLARE     @SQL VARCHAR(MAX)
SET         @SQL = 'DECLARE @returnValue NVARCHAR(100)'
SELECT @SQL = @SQL + CHAR(13) + 'EXEC   master.dbo.xp_regread

 @rootkey      = N''HKEY_LOCAL_MACHINE'',
 @key          = N''SOFTWAREMicrosoftMicrosoft SQL Server' + RegPath + 'MSSQLServer'',
 @value_name   = N''DefaultData'',
 @value        = @returnValue OUTPUT; 

 UPDATE #tempInstanceNames SET DefaultDataPath = @returnValue WHERE RegPath = ''' + RegPath + '''' + CHAR(13) FROM #tempInstanceNames 

 -- now, with these results, you can search the reg for the values inside reg
 EXEC (@SQL)
 SELECT      InstanceName, RegPath, DefaultDataPath
 FROM        #tempInstanceNames

Trouble Shooting Network configurations

SELECT registry_key, value_name, value_data  
FROM sys.dm_server_registry  
WHERE registry_key LIKE N'%SuperSocketNetLib%';  

Server Error in ‘/’ Application.

A network-related or instance-specific error occurred while establishing a 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’m not sure, after I created a network service the problem occurs:

USE [master];
CREATE LOGIN [NT AUTHORITYNETWORK SERVICE] FROM WINDOWS;
EXEC sp_addsrvrolemember N'NT AUTHORITYNETWORK SERVICE', SYSADMIN;

I have tried to use different connection string to test my connection

Data Source=(localdb)mssqllocaldb
//publishing and compiling error

But if I build & publish templating direct to local IP for the connection string, the error does not appear…

Data Source=192.168.100.233
//compiling error

I have no idea about this problem..

  • Remove From My Forums

 none

SQL Network Interfaces, error: 50 — Local Database Runtime error occurred

  • Question

  • I installed the new version of SQL but I am still getting this same error : 

    //Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

    //string temp = @"Data Source=MOXL0063TEW_SQLEXPRESS; Integrated Security = True"; string temp = @"Data Source=(LocalDB)v11.0;AttachDbFilename='C:App_DataWrestling.mdf';Integrated Security=True"; // string temp = @"Data Source=(LocalDB)MSSQLSERVER;AttachDbFilename='C:App_DataWrestling.mdf';Integrated Security=True";

    but nothing is working… why?

    A network-related or instance-specific error occurred while establishing a 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
    

    I have a service that can pull data from a (LocalDB)MSSQLLocalDB database.
    This works fine on my computer, but then I run the service on my AWS server and it does not work

  • Remove From My Forums
  • Question

  • From Robert Luongo @RobertLuongo via Twitter

    I got stuck at the point when you need to run the update-database command on the NuGet Package Console. I have followed all exact instructions, and the default connection string that has been created is as follows. <add name=»DefaultConnection»
    connectionString=»Data Source=(LocalDb)MSSQLLocalDB;AttachDbFilename=|DataDirectory|aspnet-ContactManager-20160302022257.mdf;Initial Catalog=aspnet-ContactManager-20160302022257;Integrated Security=True» providerName=»System.Data.SqlClient»
    />.

    When I run the update-database command I get the following error: A network-related or instance-specific error occurred while establishing a 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. The specified LocalDB instance does not exist. Using NuGet Package Manager 3.3.0 with Visual Studio 2015 Community
    Version 14.0.24720.00.

    EDIT: This is now sorted !! :)

    Issue was as you anticipated the NuGet Package Manager was not able to create the instance specified in the DefaultConnection string. Data Source=(LocalDb)MSSQLLocalDB. I changed it to Data Source=(LocalDB)v11.0 and it now works, probably this is how the
    instance should be specified when using SQL Express Edition ??

    Thanks,
    @AzureSupport


    Thiene Schmidt

    • Edited by

      Thursday, March 3, 2016 11:33 AM

Answers

  • Yes SQL Express Edition will throw an instance specific error when using Data Source=(LocalDb)MSSQLLocalDB
    in connection string, the only way I got it to work was by changing it to 
    (LocalDB)v11.0 , so is that
    actually an SQL Express Edition issue ??? or is it caused by something else ?? thanks !!

    • Proposed as answer by
      Casey KarstMicrosoft employee
      Friday, March 4, 2016 11:52 PM
    • Marked as answer by
      Casey KarstMicrosoft employee
      Monday, March 7, 2016 3:54 PM

Я пытаюсь создать веб-приложение ASP.NET MVC 5 с файлом MyDatabase.mdf в папке App_Data. У меня установлен SQL Server 2014 Express с экземпляром LocalDb. Я могу редактировать таблицы базы данных с помощью Server Explorer, однако, когда я отлаживаю приложение и перехожу на страницу, где нужна база данных, я получаю следующую ошибку.

При установлении соединения с SQL Server возникла связанная с сетью или конкретная ошибка экземпляра. Сервер не найден или не был доступен. Проверьте правильность имени экземпляра и настройте SQL Server для удаленного подключения. (провайдер: Сетевые интерфейсы SQL, ошибка: 50 — Произошла ошибка локальной базы данных. Невозможно создать автоматический экземпляр. См. журнал событий приложения Windows для получения подробных сведений об ошибке.

Итак, я посмотрел в средстве просмотра событий в разделе Application и снова вижу одно предупреждение снова и снова.

Недопустимый каталог, предназначенный для кэширования сжатого содержимого. C:UsersUser1AppDataLocalTempiisexpressIIS Временные сжатые файлы Clr4IntegratedAppPool. Статическое сжатие отключается.

Поэтому я попытался перезагрузить сервер, но все равно не пошел. Такая же ошибка 50, как и раньше.

Я создал класс под Models, где у меня есть класс под названием Post.

namespace MyApplication.Models
{
    public class Post
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
    }

    public class MyDatabase : DbContext
    {
        public DbSet<Post> Posts { get; set; }
    }
}

У меня также есть настройка Controller, чтобы перечислять сообщения из MyDatabase.

namespace MyApplication.Controllers
{
    public class PostsController : Controller
    {
        private MyDatabase db = new MyDatabase();

        // GET: Posts
        public ActionResult Index()
        {
            return View(db.Posts.ToList());
        }
    }

В моем файле web.config строка подключения выглядит так:

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=(LocalDB)v12.0;AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

Я пробовал предлагаемое предложение здесь, но это не сработало. Также попробовал этот.

Я также замечаю, что экземпляр MyDatabase отключается после запуска приложения. Если я обновляю базу данных с помощью Server Explorer в Visual Studio, я могу просмотреть таблицы.

Как я могу подключиться к базе данных и отредактировать ее в Visual Studio 2013, но когда я отлаживаю приложение, он не может подключиться к базе данных?

Понравилась статья? Поделить с друзьями:
  • Error 1044 42000 access denied for user ошибка
  • Error 1004 ошибка при вызове
  • Error 1001 неизвестная ошибка 0x80005000
  • Error 064 пульсар как сбросить ошибку
  • Error 017 undefined symbol ошибка