命名管道错误 40,通过 visual studio 连接到 Xampp

Named pipes error 40, connecting to Xampp through visual studio

我已经将 Xampp 设置为服务器来托管我的数据库。

我正在尝试连接到数据库,过滤结果并根据 txtSearch 中的文本将它们输出到 datagridview

 private void btnTest_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=epas;Persist Security Info=True;uID=root;Password=Password");
        con.Open();
        SqlDataAdapter ada = new SqlDataAdapter("SELECT ID, Description, Retail FROM pricing where ID like'" + txtSearch.Text + "%'", con);
        DataTable dt = new DataTable();
        ada.Fill(dt);
        dataGridView1.DataSource = dt;
        con.Close();
    }
}

但是每次我 运行 我都会得到同样的错误

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

如果我输入错误的详细信息,我将无法访问,但我已多次更改连接字符串,无法连接

我正在使用更新的 Xampp 和 visual studio 2013

好的愚蠢的问题时间,xamp 是 apache,mysql,php 和 perl。那么您是否正在尝试连接到 mysql 数据库。如果是这样,您使用的是错误的数据适配器,您使用的是 mssql 数据适配器,您将需要 mysql 一个,例如 https://dev.mysql.com/downloads/connector/net/6.8.html

如果您正在连接到 mssql 数据库,例如其中一个快速版本,请忽略。