Ошибка сервера в приложении ' / ' - LINQ
Я получил эту ошибку. Его работа локальная, но не онлайн
Система не может найти указанный файл
[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.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +356 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +117 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +267 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +318 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +132 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +195 System.Data.SqlClient.SqlConnection.Open() +122 System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user) +59 System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() +43 System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() +27 System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +70 System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<t>.GetEnumerator() +54 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +432 System.Linq.Enumerable.ToList(IEnumerable`1 source) +70 Blognyhederdp.Page_Load(Object sender, EventArgs e) +284 System.Web.UI.Control.OnLoad(EventArgs e) +109 System.Web.UI.Control.LoadRecursive() +68 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3321 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.81.0
Что я уже пробовал:
Я использую это в codebhind, и он работает локально
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Globalization; public partial class Blognyhederdp : System.Web.UI.Page { DataClassesDataContext db = new DataClassesDataContext(); protected void Page_Load(object sender, EventArgs e) { Repeater_Visnyhed.DataSource = db.Posters.OrderByDescending(n => n.Postdate).Take(5).ToList(); Repeater_Visnyhed.DataBind(); } }
Richard MacCutchan
Посмотрите на сообщение. Он ясно говорит вам, что какой бы путь вы ни настроили для своего SQL-сервера, он недействителен или не может быть достигнут.
Dave Kreskowiak
Обычно это происходит потому, что ваша строка подключения неверна. Он не указывает ни на SQL Server должным образом, ни на ваш путь к файлу базы данных, который нужно прикрепить в SQL Server Express, неправильно.