.NET Core 2-具有实例名称和端口号的连接字符串 [英] .NET Core 2 - Connection string with instance name and port number

查看:202
本文介绍了.NET Core 2-具有实例名称和端口号的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我的配置中有一个连接字符串。此应用程序使用.NET core 2.11和SQL Server创建。这是连接字符串:

In my application I have a connection string in the config. This application created using .NET core 2.11 and SQL Server. This is the connection string:

Data Source=servername\instancename, portnumber;Initial Catalog=dbname;Persist Security Info=True;User ID=username;Password=password;

此字符串会导致错误,如下所示:

This string causes an error as shown here:

如果我在字符串中使用实例名称和端口号,则会发生此错误。如果我删除其中任何一个,则它可以工作。那么,如何在连接字符串中同时使用实例名称和端口号呢?

This error happens if I use instance name and port number in the string. If I remove either one, it is working. So, how do I make it work to used both instance name and port number in the connection string?

推荐答案

找到了答案。实例名称将使用动态端口,因此我无法使用默认端口号(1433)。需要将端口号更改为使用1433而不是动态端口。

Found the answer. Instance name will be use dynamic port, so I cannot use default port number (1433). Need to change the port number to used 1433 instead of the dynamic port.

这篇关于.NET Core 2-具有实例名称和端口号的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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