c# - 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" />
但无法连接到数据库
请帮忙。
解决方案
推荐阅读
- javascript - 组织后端(Node)进程和使用这些进程的一部分的前端(Vue / Nuxt)的最佳方式
- c# - 是否有一种通用方法可以将当前用户转换为其角色之一,例如管理员?
- sql-server - 如何通过查询从组内的其他表中获取数据?
- java - 使用 ByteBuddy 的检测不适用于 3-rd 方类
- javascript - 在本地服务器中,我们的 Ajax 代码正在工作,同时当我们在 Live 服务器中部署时,它不工作
- python - Python:根据给定索引使用现有 df 中的行创建新数据框
- javascript - 事件监听器 Javascript
- java - 将 For-Loop 转换为 Java 流
- python - 检查过去的日期是否是工作日
- xml - WixUI_Mondo 和 WixUI_InstallDir