Hi,
I developed a .net site on my computer where everything works fine. Now I want to publish it on my server but I can’t get the web application to reach the SQL Server (or at least I think that’s the problem). OS is Windows Server 2008 R2 with SQL Server 2012.
I already checked if the connectionstring is correct, enabled SQL Server Browsing, granted permission of the NETWORK SERVICE to the database folder, and ran through a lot of forums but I couldn’t find anything. The error message I receive is the following:
<title>The system cannot find the file specified</title><meta content=»width=device-width» name=»viewport» /><style>body {font-family:»Verdana»;font-weight:normal;font-size: .7em;color:black;} p {font-family:»Verdana»;font-weight:normal;color:black;margin-top:
-5px} b {font-family:»Verdana»;font-weight:bold;color:black;margin-top: -5px} H1 { font-family:»Verdana»;font-weight:normal;font-size:18pt;color:red } H2 { font-family:»Verdana»;font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:»Consolas»,»Lucida Console»,Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable
{ text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px;
} } </style>
Server Error in ‘/’ Application.
The system cannot find the file specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file specified] [SqlException (0x80131904): 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.)] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6675286 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +688 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +6701832 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +219 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6703968 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6704427 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +610 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1049 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +74 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +6706995 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +78 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2192 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1012 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6711619 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +152 System.Data.SqlClient.SqlConnection.Open() +229 System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action`1 act) +134 System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +3790907 System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +10941050 System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +91 [ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.] System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +10941121 System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +48 [ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.] System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +242 System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +82 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +88 System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +248 System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +524 System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps() +23 System.Data.Entity.Database.Exists() +40 System.Web.Providers.ModelHelper.EnsureDatabaseCreated(DbContext db) +66 System.Web.Providers.DefaultMembershipProvider.ValidateUser(String username, String password) +207 System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +105 System.Web.UI.WebControls.Login.AttemptLogin() +160 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +93 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +84 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
Thanks for your help in advance,
András
I programmed an application with an attached .mdf
database file that works fine on my computer. But on another computer (client PC) I get this error message :
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.)]
System.Data.SqlClient.SqlInternalConnection
Should I install SQL Server Express on my client PC? It’s just impossible, can you please help ?
Thanks in advance
marc_s
722k173 gold badges1320 silver badges1443 bronze badges
asked Apr 18, 2016 at 21:28
2
If you want to use a .mdf
SQL Server database file, you must install at least SQL Server Express on that machine — or put the database on a SQL Server instance in the network the PC is connected to and use the database on the server.
You cannot use a .mdf
database file totally without installed SQL Server — SQL Server is not an embedded database that works without installation. If you require such a database, look at SQLite, SQL Server CE (Compact Edition) or something like RavenDB. Those can be embedded (as a set of DLL’s) into your solution and work against files on disk without need of installing a server component on the machine where they run.
answered Apr 19, 2016 at 6:41
marc_smarc_s
722k173 gold badges1320 silver badges1443 bronze badges
I have repeat many times once I do this
PMC
Add-Migration Initial
Update-Database
Then I get the 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: 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.)
And when I connect to :
Home page is OK :https://localhost:44317/
Moview page:https://localhost:44317/movies, then have a error as following:
An unhandled exception occurred while processing the request.
Win32Exception: The system cannot find the file specified
Unknown location
SqlException: 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.)
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, object providerInfo, string newPassword, SecureString newSecurePassword, bool redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, bool applyTransientFaultHandling, string accessToken)
System.Linq.AsyncEnumerable.Aggregate_<TSource, TAccumulate, TResult>(IAsyncEnumerable source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken) in Aggregate.cs
RazorPagesMovie.Pages.Movies.IndexModel.OnGetAsync() in Index.cshtml.cs
}
public IList<Movie> Movie { get;set; }
public async Task OnGetAsync()
{
Movie = await _context.Movie.ToListAsync();
}
}
}
and this line Movie = await _context.Movie.ToListAsync(); marked red
0 / 0 / 0 Регистрация: 13.05.2015 Сообщений: 27 |
|
1 |
|
VS 2013 Не видит локальную базу данных16.06.2015, 15:30. Показов 4692. Ответов 7
Добрый день. Прошу помочь срочно, послезавтра дипломирование, а на ноутбуке кафедры не работает моя прога. Программа использует локальную базу данных .mdf, и при обращении к ней, выдает ошибку SqlException (0x80131904): 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.) Я создавал приложение в Visual Studio 2013 и дома программа прекрасно работала на ноутбуке и настольном компе. А на кафедре не работает. В чем дело и как решить эту проблему?
__________________
0 |
8893 / 5668 / 1351 Регистрация: 25.05.2015 Сообщений: 17,215 Записей в блоге: 14 |
|
16.06.2015, 15:34 |
2 |
Установить на демонстрационном компьютере сервер вашей базы данных и скопировать туда базу.
0 |
36 / 36 / 15 Регистрация: 08.12.2014 Сообщений: 171 |
|
16.06.2015, 15:37 |
3 |
посмотрите свойства файла с БД, возможно она не копируется в нужную директорию
0 |
0 / 0 / 0 Регистрация: 13.05.2015 Сообщений: 27 |
|
16.06.2015, 17:01 [ТС] |
4 |
В свойствах базы я указывал «do not copy to output», потому что читал что тогда она будет при запуске заменяться на пустую, и базу нужно просто положить рядом с экзешником (в Debug). На моем компе и ноуте это работало, наверное потому что там стояла студия и был сразу sql server нужный. А на кафедре студия 2010. Сейчас попробую установить msi, может сработает. Добавлено через 1 час 3 минуты
0 |
8893 / 5668 / 1351 Регистрация: 25.05.2015 Сообщений: 17,215 Записей в блоге: 14 |
|
16.06.2015, 17:04 |
5 |
«Invalid value for key ‘attachdbfilename'»
0 |
0 / 0 / 0 Регистрация: 13.05.2015 Сообщений: 27 |
|
16.06.2015, 17:17 [ТС] |
6 |
Какие именно настройки? Меня смущает, что где-то работает после установки SQLLocalDB, а где-то нет, хотя и ошибка другая.
0 |
8893 / 5668 / 1351 Регистрация: 25.05.2015 Сообщений: 17,215 Записей в блоге: 14 |
|
16.06.2015, 17:18 |
7 |
ConnectionString в Код <add name="MovieDBContext" connectionString="Data Source=.;Initial Catalog=Movies;AttachDbFilename=|DataDirectory|Movies.mdf;Integrated Security=True" providerName="System.Data.SqlClient" /> изменить Data Source в: Data Source=.; или Data Source=.SQLEXPRESS;
0 |
HorusWarmaster 0 / 0 / 0 Регистрация: 13.05.2015 Сообщений: 27 |
||||
16.06.2015, 22:00 [ТС] |
8 |
|||
У меня так стоит, вроде нормально должно быть
0 |
Have you been using LocalDB for your development machine and it works perfectly fine. But when you deploy your application together with LocalDB to another machine, it just failed to connect to the LocalDB.
You may see a similar error message as follows.
System.Data.SqlClient.SqlException (0x80131904): 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.)
What the above message meant is that the machine you deployed does not have a Local Database Runtime installed. So before we proceed to solve the above issue, let’s look through certain things.
If your localDB is created from Visual Studio 2013, then your localDB would have version 11.0. To view the version in detail, just execute the query «SELECT @@VERSION». You can execute the query through SQL Server Management Studio or Visual Studio 2013.
Microsoft SQL Server 2012 (SP1) — 11.0.3000.0 (X64)
Oct 19 2012 13:38:57
Copyright (c) Microsoft Corporation
Express Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
Next, we have to download the SqlLocalDB.msi from http://www.microsoft.com/en-us/download/details.aspx?id=29062. Depending on your server machine, pick 32Bit or 64Bit.
If your LocalDB version is version 12.0 or SQL Server 2014, then you may need to get the SqlLocalDB.msi from this link instead http://www.microsoft.com/en-my/download/details.aspx?id=42299.
UPDATE: With the release of SQL Server 2016, you can now get the LocalDB version 13.0 here https://www.microsoft.com/en-us/download/details.aspx?id=52679.
After you have downloaded it, install it to the machine that contains your application that is facing the above error. The installation is pretty much straightforward and remember to read the terms and condition before proceed with the installation
After you have done the installation, your application should now be able to connect to the LocalDB.
For more details : http://www.mssqltips.com/sqlservertip/2694/getting-started-with-sql-server-2012-express-localdb/
If you do hit with another error when your web application is deployed to IIS and is accessing to LocalDB, you may want to check it out here http://jaryl-lan.blogspot.com/2016/06/localdb-connecting-to-localdb-failed.html
Forum Rules |
|
подключаю локальную бд, на моем пк работает все, на другом не работает хотя путь к файлу задается автоматически
ругается именно на подключение к бд.
«************ Exception Text **************
System.Data.SqlClient.SqlException (0x80131904): 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.) —> System.ComponentModel.Win32Exception (0x80004005): Не удается найти указанный файл»
string file = @"Database1.mdf";
string path = Path.Combine(Environment.CurrentDirectory);
string full_fille = path + file;
connect = @"Data Source = (LocalDB)MSSQLLocalDB; AttachDbFilename="+full_fille+";Integrated Security = True";
проект «https://yadi.sk/d/lORIhaWv0fXRlA»