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"`
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
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
Problem Description:
I am trying to build an ASP.NET MVC 5 Web Application which has a MyDatabase.mdf
file in the App_Data
folder. I have SQL Server 2014 Express installed with a LocalDb
instance. I can edit the database tables using the Server Explorer, however when I debug the application and go to a page where the database is needed 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. Cannot create an automatic instance. See the Windows Application event log for error details.
So I looked in the Event Viewer under Application
and only see one Warning over and over again.
The directory specified for caching compressed content C:UsersUser1AppDataLocalTempiisexpressIIS Temporary Compressed FilesClr4IntegratedAppPool is invalid. Static compression is being disabled.
So I tried rebooting the server, still no go. Same error 50 as before.
I have created an class under Models
where I have a class called 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; }
}
}
I also have a Controller
setup to list the posts from MyDatabase
.
namespace MyApplication.Controllers
{
public class PostsController : Controller
{
private MyDatabase db = new MyDatabase();
// GET: Posts
public ActionResult Index()
{
return View(db.Posts.ToList());
}
}
In my web.config
file the connection string looks like this…
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDB)v12.0;AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
I’ve tried the suggestion posted here but it didn’t work. Also tried this.
I also notice that the MyDatabase instance gets disconnected after I start running the application. If I refresh the database using Server Explorer in Visual Studio I can view the tables.
How is it that I can connect to the database and edit it within Visual Studio 2013 but when I debug the application it cannot connect to the database?
Solution – 1
Breaking Changes to LocalDB: Applies to SQL 2014; take a look over this article and try to use (localdb)mssqllocaldb
as server name to connect to the LocalDB automatic instance, for example:
<connectionStrings>
<add name="ProductsContext" connectionString="Data Source=(localdb)mssqllocaldb;
...
The article also mentions the use of 2012 SSMS to connect to the 2014 LocalDB. Which leads me to believe that you might have multiple versions of SQL installed – which leads me to point out this SO answer that suggests changing the default name of your LocalDB “instance” to avoid other version mismatch issues that might arise going forward; mentioned not as source of issue, but to raise awareness of potential clashes that multiple SQL version installed on a single dev machine might lead to … and something to get in the habit of in order to avoid some.
Another thing worth mentioning – if you’ve gotten your instance in an unusable state due to tinkering with it to try and fix this problem, then it might be worth starting over – uninstall, reinstall – then try using the mssqllocaldb
value instead of v12.0
and see if that corrects your issue.
Solution – 2
Running this:
sqllocaldb create “v12.0”
From cmd prompt solved this for me…
Solution – 3
I usually fix this errore following this msdn blog post Using LocalDB with Full IIS
This requires editing applicationHost.config file which is usually located in C:WindowsSystem32inetsrvconfig. Following the instructions from KB 2547655 we should enable both flags for Application Pool ASP.NET v4.0, like this:
<add name="ASP.NET v4.0" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>
Solution – 4
Final Solution for this problem is below :
-
First make changes in applicationHost config file. replace below string setProfileEnvironment=”false” TO setProfileEnvironment=”true”
-
In your database connection string add below attribute : Integrated Security = SSPI
Solution – 5
I ran into the same problem. My fix was changing
<parameter value="v12.0" />
to
<parameter value="mssqllocaldb" />
into the “app.config” file.
Solution – 6
maybe this error came because this version
of Sql Server is not installed
connectionString="Data Source=(LocalDB)v12.0;....
and you don’t have to install it
the fastest fix is to change it to any installed version you have
in my case I change it from v12.0
to MSSQLLocalDB
Solution – 7
All PLEASE note what Tyler said
Note that if you want to edit this file make sure you use a 64 bit text editor like notepad. If you use a 32 bit one like Notepad++ it will automatically edit a different copy of the file in SysWOW64 instead. Hours of my life I won’t get back
Solution – 8
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"`
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%';
Solution – 9
An instance might be corrupted or not updated properly.
Try these Commands:
C:>sqllocaldb stop MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" stopped.
C:>sqllocaldb delete MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" deleted.
C:>sqllocaldb create MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" created with version 13.0.1601.5.
C:>sqllocaldb start MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" started.
Solution – 10
In my case, we had several projects in one solution and had selected a different start project than in the package manager console when running the “Update-Database” Command with Code-First Migrations.
Make sure to select the proper start project.
Solution – 11
I have solved above problem Applying below steps
And after you made thses changes, do following changes in your web.config
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)v12.0;AttachDbFilename=|DataDirectory|aspnet-Real-Time-Commenting-20170927122714.mdf;Initial Catalog=aspnet-Real-Time-Commenting-20170927122714;Integrated Security=true" providerName="System.Data.SqlClient" />
Solution – 12
My issue was that i had multiple versions of MS SQL express installed. I went to installation folder C:Program FilesMicrosoft SQL Server
where i found
3 versions of it. I deleted 2 folders, and left only MSSQL13.SQLEXPRESS which solved the problem.
GENDALF_ISTARI 16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
||||||||
1 |
||||||||
08.02.2016, 01:14. Показов 13521. Ответов 12 Метки нет (Все метки)
Проблема подключения к серверу базы Publich->File публикуем проект в отдельную папку А как подключать SQL к IIS серверу то возникает проблема Вот строка Web.Config которую подключаю в IIS
Строка подключения локальная обычная вот Web.Config
Проект ссылка вот: WebApplication_base_test_manual.rar К сожалению выводит вот (Как решить проблему товарищи) Миниатюры
0 |
Администратор 15621 / 12590 / 4990 Регистрация: 17.03.2014 Сообщений: 25,586 Записей в блоге: 1 |
|
08.02.2016, 14:24 |
2 |
GENDALF_ISTARI, в ошибке сказано что в журнале событий была сделана запись с инфорамацией об ошибке. Найди её и выложи сюда.
1 |
11485 / 7827 / 1193 Регистрация: 21.01.2016 Сообщений: 29,341 |
|
08.02.2016, 17:38 |
3 |
Не пытайтесь использовать LocalDB для работы из под IIS. Настройке нормальный сервер баз данных. Или, если вам так принципиально, то убедитесь, что у учётки из под которой работает пул веб-приложения есть права на создание экземпляра LocalDB и права на чтение файла базы данных. Добавлено через 3 минуты
1 |
16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
|
08.02.2016, 18:07 [ТС] |
4 |
хорошо Найду шас выложу , честно не понимаю IIS он что должен иметь пароль и логин в строке в Web.Config для персонального входа не пойму где это и как видить
0 |
16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
|
08.02.2016, 18:39 [ТС] |
5 |
Вот нашел журнал называется там папки я упаковал в архив LogFiles.rar их, и прикрепил к вашему серваку))
0 |
Администратор 15621 / 12590 / 4990 Регистрация: 17.03.2014 Сообщений: 25,586 Записей в блоге: 1 |
|
08.02.2016, 18:58 |
6 |
Вот нашел журнал называется Это не то. Речь идет о журнале событий Windows который просматривается с помощью Event Viewer.
1 |
16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
|
08.02.2016, 19:30 [ТС] |
7 |
Администрирвание->Просмотр событий На фото события Миниатюры
0 |
11485 / 7827 / 1193 Регистрация: 21.01.2016 Сообщений: 29,341 |
|
08.02.2016, 19:55 |
8 |
GENDALF_ISTARI, я же вам уже написал в чём ваша проблема. Ссылку даже предоставил, где описано решение. Вот она, на случай, если вы не увидели мой прошлый пост. Вам нужно настроить IIS на загрузку профиля пользователя, для корректной работы LocalDB.
1 |
GENDALF_ISTARI 16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
||||||||||||
08.02.2016, 20:09 [ТС] |
9 |
|||||||||||
Ех Usaga я не пойму как это делать и Подключению в IIS в строке подключения Я не пойму эту разницу куда строку ту пихать в той статье как же ту строку пихать ? Ну вот IIS->Строки подключения
Куда мне тулить эту строку ?
если я шас сделаю так пул .NET v4.5 Classic
то IIS->Строки подключения и куда это тулить в той статье ? хоть пример правильного подключения IIS есть ?
0 |
11485 / 7827 / 1193 Регистрация: 21.01.2016 Сообщений: 29,341 |
|
08.02.2016, 20:23 |
10 |
Изменения нужно внести в файл Добавлено через 1 минуту
1 |
GENDALF_ISTARI 16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
||||||||||||||||
09.02.2016, 10:10 [ТС] |
11 |
|||||||||||||||
Нашол участок в файле %SystemRoot%inetsrvconfigapplicationHost.config
добавив ( loadUserProfile=»true» setProfileEnvironment=»true»)
Или на теге .NET v4.5 Classic их добавить
Еще вопрос на счет самой строки в проекте Web.Config
И что менять и как ? Добавлено через 13 часов 30 минут
0 |
GENDALF_ISTARI 16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
||||
11.02.2016, 23:11 [ТС] |
12 |
|||
Ошибка Local Database Runtime IIS MVC файле %SystemRoot%inetsrvconfigapplicationHost.config
Как решить проблему товарищи ? Миниатюры
0 |
16 / 33 / 19 Регистрация: 20.08.2013 Сообщений: 740 |
|
21.02.2016, 18:51 [ТС] |
13 |
Тема закрыта вот мой пример
0 |