我该如何解决这个问题? [英] How Do I Resolve This Issue?

查看:63
本文介绍了我该如何解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void GetBackup(string strDBName)
{
    if (string.IsNullOrEmpty(strDBName))
    {
        MessageBox.Show("Server Name & Database can not be Blank");
        return;
    }
    else
    {                
        string destinationPath = ConfigurationManager.AppSettings.Get("BackupDestinationPath");
        

BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
            
          
             ServerConnection connection = new ServerConnection(ConfigurationManager.ConnectionStrings["CostAllocationEntities2"].ConnectionString);               
           
            Server sqlServer = new Server(connection);                
            Database db = sqlServer.Databases[strDBName];



以上行数据库db = sqlServer.Databases [strDBName];导致下面提到的错误。



错误:建立与SQL Server的连接时发生网络相关或特定于实例的错误。服务器未被>找到验证实例名称是否正确以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)}



消息:无法连接到服务器数据

来源= PC210090 \\SQLEXPRESS;初始目录= testdb2;坚持安全

信息= True;用户ID = sa;密码=密码-1}


The above line Database db = sqlServer.Databases[strDBName]; is causing the below mentioned error.

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: 26 - Error Locating Server/Instance Specified)"}

Message : Failed to connect to server Data
Source=PC210090\\SQLEXPRESS;Initial Catalog=testdb2;Persist Security
Info=True;User ID=sa;password=password-1"}

推荐答案

此错误消息通知您无法连接到SQL Server。您需要解决你的数据库连接问题。



可能的原因及其消除在下面的链接中描述:

要做的事情ck解决建立与SQL Server的连接时发生网络相关或特定于实例的错误 [ ^ ]





- Amy
This error message informs you that it is not possible to connect to SQL Server.You need to troubleshoot your DB connection.

The possible reasons and their elimination is described in below link:
7 things to check to resolve "A network-related or instance-specific error occurred while establishing a connection to SQL Server[^]


--Amy


我认为更简单的方法是在连接字符串中指定数据库名称。因此,您的连接字符串将如下所示:



I think more easiest way is to specify the database name within the connection string. So your connection string will be looks like:

<add key="connectionstring" value="Server=myserver;Initial Catalog=myDatabase_name;Persist Security Info=True;MultipleActiveResultSets=True;User ID=****;Password=****;Max Pool Size=90;" />


这篇关于我该如何解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆