C# SQL网络接口,错误:50-发生本地数据库运行时错误

C# SQL网络接口,错误:50-发生本地数据库运行时错误,c#,sql-server,C#,Sql Server,我有一个可以从(LocalDB)\MSSQLLocalDB数据库中提取数据的服务。这在我的计算机上运行正常,但随后我在AWS服务器上运行该服务,并尝试从数据库中提取数据。我收到以下错误: 建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:50-发生本地数据库运行时错误。指定的LocalDB实例不存在。) 我的连接代码是: SqlConne

我有一个可以从
(LocalDB)\MSSQLLocalDB
数据库中提取数据的服务。这在我的计算机上运行正常,但随后我在AWS服务器上运行该服务,并尝试从数据库中提取数据。我收到以下错误:

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:50-发生本地数据库运行时错误。指定的LocalDB实例不存在。)

我的连接代码是:

    SqlConnection conn;
    SqlCommand comm;
    SqlConnectionStringBuilder connStringBuilder;

    void ConnectToDb()
    {
        connStringBuilder = new SqlConnectionStringBuilder();
        connStringBuilder.DataSource = @"(LocalDB)\MSSQLLocalDB";//"(LocalDB)\v11.0";
        connStringBuilder.InitialCatalog = "WRESTLING.MDF";
        connStringBuilder.Encrypt = true;
        connStringBuilder.ConnectTimeout = 30;
        connStringBuilder.AsynchronousProcessing = true;
        connStringBuilder.MultipleActiveResultSets = true;
        connStringBuilder.IntegratedSecurity = true;
        string location = Directory.GetCurrentDirectory();
        //Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
        string temp = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\App_Data\Wrestling.mdf';Integrated Security=True";
       // string temp = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='F:\Projects\Bailey Service\Bailey Service\App_Data\Wrestling.mdf';Integrated Security=True";
        conn = new SqlConnection(temp);
        comm = conn.CreateCommand();
    }
我的数据库在我的计算机和服务器上都位于同一位置。我的服务器上安装了Microsoft SQL Server Management Studio,我可以连接并查看该服务器上的
摔跤.MDF
数据库

我在服务器上运行SQL Server(
SQLEXPRESS
)。但它是否应该是正在运行的SQL Server(
MSSQLLocalDB
)?我看不到那个。这就是问题所在吗?还是别的什么

我的服务是在服务器上运行的,因为我可以从中提取数据库中不存在的数据。只有从数据库中提取的功能在服务器上不起作用

更新:

我暂停了SQL的新版本,但仍然遇到相同的错误:

我试过:

 //Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
        //  string temp = @"Data Source=MOXL0063\TEW_SQLEXPRESS; Integrated Security = True";
          string temp = @"Data Source=(LocalDB)\v11.0;AttachDbFilename='C:\App_Data\Wrestling.mdf';Integrated Security=True";
       // string temp = @"Data Source=(LocalDB)\MSSQLSERVER;AttachDbFilename='C:\App_Data\Wrestling.mdf';Integrated Security=True";
但是什么都没用。。。 为什么?

服务器堆栈跟踪: 在System.ServiceModel.Channels.ServiceChannel.ThrowiffaultUnderstanding处(消息回复、消息故障、字符串操作、消息版本、故障转换器故障转换器) 位于System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime操作,ProxyRpc&rpc) 在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作、布尔单向、ProxyOperationRuntime操作、对象[]输入、对象[]输出、时间跨度超时) 位于System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage方法调用,ProxyOperationRuntime操作) 位于System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)

在[0]处重试异常: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) at System.Runtime.Remoting.proxy.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型) 在IService1.nextmatch(日期时间项) 在Service1Client.nextmatch(日期时间项)


如何找到正确的实例>

转到并修复您的连接信息。(LocalDb)与本地SQL Server express不同。这给了。。。。“\SqlExpress”作为服务器。顺便说一句,它需要有AttachDbFileName(它还能用吗?Express已经10年没有使用了),因为它不会自动附加MDF文件。

如果您使用的是Amazon RDS Db,则需要先下载驱动程序,然后连接到数据库。也许这可以帮助您连接数据库。

sqlexpress不是localdb。使用您在ManagementStudio中看到的实例名称。此外,读取错误消息也非常有帮助。找不到服务器意味着不,您不会打开“我在服务器中有问题”的异常。同样,如果你的车被偷了,它也不会坏。不,(LocalDB)不是本地SQLServerExpress。是否有您需要的所有连接字符串相关信息。Crowcoder,使用您在Management Studio中看到的实例名称是什么意思?在哪里使用它?好吧,我想我不明白,因为它在调试模式下在我的labtop上工作。我可以连接到数据库并提取数据,那么为什么connectionstring现在出错了呢?最有可能的情况是,在调试模式下,您的笔记本电脑正在使用localldb。SqlExpress!=localdb。在我的机器上工作=它的标准问题。TomTom-我刚刚更新了帖子,你能看一下吗?Scott Chamberlain-我刚刚更新了帖子,你能看一下吗?不,出于原则。一个问题,一个答案。还有一个问题吗?当然再问一个问题。我回答了你问的问题。你的更新完全不同。
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.)