简体   繁体   English

C#-错误26-定位指定的服务器/实例

[英]C#-Error 26- Locating Server/Instance Specified

I am attempting to run a program that gets data from a remote SQL Server, but when I run the program the debugger says "Error Locating Server/Instance Specified" 我试图运行一个从远程SQL Server获取数据的程序,但是当我运行该程序时,调试器显示“错误定位服务器/实例已指定”

I searched the web and Stack Overflow and tried many things, but nothing worked! 我在网上搜索了Stack Overflow,并尝试了很多方法,但是没有任何效果!

What am I doing wrong here? 我在这里做错了什么?

private void txtsearch_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection("Server=.\\MSSQLSERVER;AttachDbFilename = C:\\Program Files\\Microsoft SQL Server\\MSSQL11.MSSQLSERVER\\MSSQL\\DATA\\Education.mdf; Database= education;Trusted_Connection=Yes;");
        DataTable dt = new DataTable();
        SqlDataAdapter SDA = new SqlDataAdapter("Select * From Education Where NationalKey "+ txtNationalKey.Text, conn);
        SDA.Fill(dt);
        dataGridView1.DataSource = dt;

    }

I tried MSSQL11,SQL Express and many other format of string. 我尝试了MSSQL11,SQL Express和许多其他格式的字符串。 I opened UDP port 1434,TCP port 1433 and 7200 too. 我也打开了UDP端口1434,TCP端口1433和7200。

.\\\\ in your connection string refer to local machine. 连接字符串中的.\\\\是指本地计算机。 Set Ip or machine name of the SqlServer machine. 设置ip或SqlServer计算机的计算机名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误 26 - 定位服务器/指定实例时出错 - error 26- error locating server/instance specified 使用C#的SQL上的错误26,指定了错误定位服务器/实例 - Error 26 on SQL with C#, error locating server / instance specified ASP.Net错误26错误定位指定的服务器/实例 - ASP.Net Error 26 Error Locating Server/Instance Specified 错误26的解决方案-指定错误的服务器/实例定位? - Solution for Error 26 - Error Locating Server/Instance Specified? SQL错误:26-查找指定的服务器/实例时出错 - SQL error:26 - Error Locating Server/Instance Specified SQL服务器错误(提供程序:SQL网络接口,错误:26-错误指定服务器/实例的位置) - SQL SERVER ERROR (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 在我的VM上:SQL网络接口,错误:26-查找指定的服务器/实例时出错 - on my VM: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified 连接数据库ASP .NET MVC 5 SQL网络接口时出现问题,错误:26-指定服务器/实例时出错 - Issue connecting to databases ASP .NET MVC 5 SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified SQL网络接口,错误:26-定位本地数据库上指定的服务器/实例时出错 - SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified on LocalDB 脚手架后的迁移问题。 (提供者:SQL 网络接口,错误:26 - 错误定位服务器/指定的实例) - Migration issue after scafolding. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM