首页 > 解决方案 > SqlDependency.Start(connection.ConnectionString) --> 无效关键字:端口

问题描述

嗨,我尝试将 signalR 添加到我的项目以获取通知。

我在 Global.asax.cs 收到错误。

当尝试执行这个 SqlDependency.Start() 我得到错误无效关键字:端口,我正在使用 postgresql 作为数据库并且连接字符串有端口我认为这就是我得到错误的原因但是我如何在使用 postgresql 时启动 sqldependency。

网页配置

  <connectionStrings><add name="connectStr" connectionString="server=localhost;port=5432;database=wfs_db;user id=postgres;password=1" providerName="Npgsql" />

<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />

全球.asax.cs

 var connectionString = ConfigurationManager.ConnectionStrings["connectStr"].ConnectionString;
        var connection = new NpgsqlConnection(connectionString); 

        SqlDependency.Start(connectionString);//get error here

我试过这个:

connectionString="server=localhost:5432;database=wfs_db;user id=postgres;password=1" providerName="Npgsql" />

但无法连接到数据库

请帮忙。

标签: c#.netasp.net-mvcpostgresqlconnection-string

解决方案


推荐阅读