当前遇到的问题是项目连接数据库报错:
在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - 无法打开到 SQL Server 的连接);
发生该问题之后排查是因为FreamWork版本与生成平台造成的;将Platformg更改为any cpu即可;
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
static void Main(string[] args) { SqlConnection connection = new SqlConnection(Constants.conn); SqlCommand getOrder = null; DataTable dt = new DataTable("Test"); try { connection.Open(); getOrder = new SqlCommand("dbo.Test", connection) { CommandType = CommandType.StoredProcedure }; getOrder.Parameters.Add(new SqlParameter("@ID", 0)); SqlDataAdapter da = new SqlDataAdapter { SelectCommand = getOrder }; da.Fill(dt); } catch (Exception e) { var test = e; } }