首页 > 解决方案 > 连接到 SQL Server(Postgresql 数据库):使用什么作为主机名?

问题描述

我正在尝试直接在 VS Code 中运行 SQL 查询,但我无法连接到数据库。我的问题是我不知道应该使用什么主机名。

当我尝试连接时,系统会提示我:

hostname\instance<server>.database.windows.netADO.NET 连接字符串

我尝试使用:

localhost:5432

但这不起作用。我错过了什么?

标签: sql-serverpostgresqlvisual-studio-codeado.net

解决方案


在此处获取服务器名称: 单击此处

SqlConnection cnx = new SqlConnection(@"data source = Server__Name ; initial catalog = Database__Name; integrated security = true");

我希望它有帮助:))


推荐阅读