首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >命名管道错误40,通过visual studio连接到Xampp

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

Stack Overflow用户
提问于 2015-05-19 08:09:26
回答 1查看 615关注 0票数 0

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

我试图连接到数据库,过滤结果,并根据txtSearch中的文本将它们输出到数据视图中。

代码语言:javascript
复制
 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();
    }
}

然而,每次我运行它时,我都会得到相同的错误。

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-03 23:36:27

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30320071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档