C#-Error 26-查找指定的服务器/实例 [英] C#-Error 26- Locating Server/Instance Specified

查看:106
本文介绍了C#-Error 26-查找指定的服务器/实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行从远程SQL Server获取数据的程序,但是当我运行该程序时,调试器会显示错误定位服务器/指定的实例



我在网上搜索并尝试了很多东西,但没有任何效果!



我在这里做错了什么?

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"

I searched the web and tried many things, but nothing worked!

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;

    }





我尝试过MSSQL11,SQL Express和许多其他格式的字符串。我也打开了UDP端口1434,TCP端口1433和7200。



I tried MSSQL11,SQL Express and many other format of string. I opened UDP port 1434,TCP port 1433 and 7200 too.

推荐答案

您已将连接字符串作为本地计算机上的实例,因此如果您正在尝试要访问远程服务器,您需要将连接字符串放入该服务器。
You have given the connection string to be an instance on the local machine so if you're trying to get to a remote server, you need to put in the connection string to that server.


这篇关于C#-Error 26-查找指定的服务器/实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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